Friday 15 March 2013

java - JPA NOT IN statement -



java - JPA NOT IN statement -

i have app uses mysql, jpa eclipselink.

i'm trying db collection of user flagged "active" , not in list loaded in application.

that method:

public list<user> findallbutusers(list<user> users) { list<user> list = null; query query = em.createquery("select u user u u not in :users , u.status = :status"); query.setparameter("status", "active"); query.setparameter("users", users); list = query.getresultlist(); homecoming list; }

and log server gives me that:

fine: select iduser, create_time, email, name, password, salt, status user ((iduser not in (?)) , (status = ?)) bind => [com.wa.gp.jpa.entities.user[ iduser=2 ], active]

from bind => [com.wa.gp.jpa.entities.user[ iduser=2 ], active] shows me instead of binding id passes value user.tostring method resulting in collection includes users passed. thought work sending object jpa , figure out iduser itself.

i don't know if expected behavior, looks me is. how can create query without having alter valor tostring in user? have instead of giving list of users pass list of ids? if case became said.

thanks

java mysql jpa eclipselink

No comments:

Post a Comment