-->
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.  [ 1 post ] 
Author Message
 Post subject: problem with criteria query
PostPosted: Fri Jan 13, 2012 12:49 pm 
Newbie

Joined: Mon Jan 09, 2012 11:49 am
Posts: 3
hi everyone,
I've a problem with a criteria query and I can't find the solution. can you help me please?
the problem is:

I've a class Contact which has a @OnetoOne relation relation which an instance of the class Address mapped on the attribute "address"

now, i need to find the list of the contact which the value of the attribute "city" equals to "xxx"

I tried doing that:
List<Contact> results = session.createCriteria(Contact.class)
.createCriteria("address")
.add(Restrictions.eq("city","xxx"))
.list();

but results is empty.

If I just do
List<Address> results = session.createCriteria(Address.class)
.add(Restrictions.eq("city","xxx"))
.list();

results contains all the instances of the class address with the "city" equals to "xxx", but i need the objects of the class Contact

thanks


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

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.