-->
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 API (Restricting by property in association)?
PostPosted: Mon Aug 28, 2006 3:12 pm 
Newbie

Joined: Wed Oct 26, 2005 1:31 am
Posts: 10
Hibernate version: 3.1.3
AuthorizationXml has a many to one relationship with MemberXml

We are having a problem translating the following HQL to the criteria API:


The query selects back auths restricting them by the member's ID:

Code:
List <AuthorizationXml> lResults = getHibernateTemplate().findByNamedParam(
"select auth from AuthorizationXml auth " +
"join auth.member mem " +
"where mem.memberId like :pMemberId",
new String[] {"pMemberId"},
new Object[] {pCriteria.getMemberId()});



Now trying this with the criteria API:

Code:
Criteria lAuthCrit = getSession()
         .createCriteria(AuthorizationXml.class)
         .createAlias("member", "mem");
lAuthCrit = lAuthCrit.add(Restrictions.like("mem.memberId", pCriteria.getMemberId()));
List<AuthorizationXml> lResults = lAuthCrit.list();


The above code selects back both the auth and the member record. I do not want to fetch the member record, I merely want to restrict by it.

We have tried all varieties of setFetchMode on the member association and the net result has been the same. Is this a bug or are we doing something wrong.

Thanks.

Tyler Van Gorder
tkv@landacorp.com
Landacorp.


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.