-->
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.  [ 3 posts ] 
Author Message
 Post subject: Restrictions with List<Object>?
PostPosted: Tue Feb 20, 2007 10:43 pm 
Newbie

Joined: Tue Feb 20, 2007 10:14 pm
Posts: 1
Hi,

I have a class called Person. This class has a property called stateVisits like this:
Code:
private List<StateVisit> stateVisits;


A StateVisit would have a State property.

A State would have code and name properties.

Now I am trying to search for all Person(s) who have visited MD. In my Restrictions in my HibernatePersonDao, I use this, but it doesn't work.

Code:
Restrictions.eq("stateVisits.state.code","MD");


It would throw me the error that it could not find property stateVisits.state.code in Person. Should it be
stateVisits.stateVisit.state.code instead? With the return type List<StateVisit>, it complicates things a bit for me.

Any help would be greatly appreciated it.

Johnny[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 11:20 pm 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi byteback.

it wont work with 3.1version.As for object modeling, If in DB 5 child record for one parent then retrieving it on some condition on child records, would cause in consistent hibernate session. Means that in session has let say on some condition has four record .If you are retrieving one parent with 4 child. But actually by association it should have 5.So to provide consistency to hibernate session they haven’t provided the filtering. Because other feature might effect like as cascade delete all orphan.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 2:34 am 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
Try the following

String queryStr = "from Person as person where person.stateVisits.state.code = 'MD'";
Query query = session.createQuery(queryStr);
List<Person> = query.list();

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.