http://www.hibernate.org/117.html

On Tue, Dec 16, 2008 at 9:41 PM, adressin <[email protected]> wrote:

>
> Hello,
>
>  We have an enum that we use for Roles, which are associated to a
> User:
>
> public class User
> {
>  private IList<UserRoles> roles;
>
>  public virtual IList<UserRoles> Roles
>  {
>    get { return roles; }
>    set { roles = value; }
>  }
> }
>
> public enum UserRoles
> {
>  Admin,
>  Purchasing,
>  ...
> }
>
> We map this in hbm file as:
>
> <bag name="UserRoles" table="APP_USER_ROLES" lazy="true"
> fetch="select">
>  <key column="USR_ID"/>
>  <element column="ROLE_ID" type="Core.Domain.UserRoles,Core.Domain"/>
> </bag>
>
> I am trying to create a criteria query with an "in" statement that
> goes against the UserRoles property using just a list of ints:
>
> IList<int> rolesToQuery = new List<int>();
> rolesToQuery.Add(1);
> rolesToQuery.Add(2);
>
> DetachedCriteria hibernateCriteria;
> ...
> ...
> hibernateCriteria.CreateCriteria("UserRoles", "uRoles").Add
> (Restrictions.InG<int>("uRoles", criteria.Roles));
>
> This fails with: collection was not an association.
>
> Any ideas how to do this query using criteria api?
>
> Kind Regards,
>  Aaron
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to