Nathan Anderson wrote:
That query seems like it should work if your users never have more than one
role. Unfortunately I don't know off the top of my head what the query should
look like if users can have more than one role.
I'd guess something like:
"from User u where ? in elements(u.roles)"
But I'd fetch the Role passed in to replace that ? from the database
rather than construct a new (non-persisted) one that will never be in
the relevant collection.
Alternately, you could add methods to Role to get/set the users with
that role. (But make sure to set the other side of that relationship as
inverse=true, join=false, and lazy=true.)
-Dale Newfield
[EMAIL PROTECTED]
----- Original Message -----
From: "Qin Ding" <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, June 5, 2007 2:41:45 PM (GMT-0800) America/Los_Angeles
Subject: [appfuse-user] User/Role Query
If I have users with different roles in the set, how can I query user
object to get a list of users with a particular role?
Role role = new Role("team lead");
getHibernateTemplate().find("from User u where u.roles = ? ", role);
Thanks.
QD
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]