-->
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: Criteria Search on Multiple Tables
PostPosted: Tue May 27, 2008 5:12 am 
Newbie

Joined: Tue May 27, 2008 4:53 am
Posts: 1
I am having a table structure similar to this.

User
- UserId
- Name
- Other Attributes

UserAddresses
- AddressId
- UserId
- StreetName
- Other Attributes

Criteria myUserCrit = mySession.createCriteria(User.class)
.createAlias("userAddresses", "userAdd")
.add(Expression.eq("UserId", 1))
.add(Expression.eq("userAdd.StreetName", "XYZ"));

List userList = myUserCrit.list();

Here the first query shown in log is correct. i.e.

Select
------
From
User
join conditions with UserAddresses using userId
Where
userId condition AND
StreetName condition.

BUT
Second query is
Select
-------
from
UserAddress
Where
userId condition Only.

The second condition is not included because of which it returns me un wanted data. Hibernate mapping file for user contains userAddresses Set containing UserAddress objects.

Please suggest.


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.