-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: IQuery expression
PostPosted: Sat Nov 08, 2008 8:32 pm 
Newbie

Joined: Fri Nov 07, 2008 9:18 pm
Posts: 4
hi

my class have a property named WorkType (enum) that added flags attribute. this property keep multiple enum value (FullTime | PartTime | Freelance). i want query using IQuery interface, but can't do it:(

my query;
(for example, my enum property value is "FullTime | PartTime | Freelance")

IQuery query = Session.CreateQuery("select a from Entity.Advert a where a.WorkType = :p1 or a.WorkType = :p2");
query.SetEnum("p1", enmWorkType.FullTime);
query.SetEnum("p2", enmWorkType.PartTime);

query.List<Entity.Advert>();

this query return 0 count

how can i do this query?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 09, 2008 11:52 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
You have to write a class wrapping your enumeration, that implements UserType.

Here is an example good for any enumeration (the 1st, simpler example is enough, unless you plan to use inheritance).

http://hibernate.bluemars.net/272.html?cmd=prntdoc

_________________
Gonzalo Díaz


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.