-->
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 projection and fetchmode
PostPosted: Tue Apr 27, 2010 5:34 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
Hello,

Situation:
user(id,login)
user_address_relation(id,user_id,address_id)
address(id,naam,street..)

Question: why are the address entities proxied when using Projection.property? The relation is fully loaded in the primary query.

Query 1:
List of proxied addresses is returned.
Code:
List<Address> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.setFetchMode("address",FetchMode.JOIN)
.setProjection(Projections.property("address")
.list();


Query 2:
Addresses inside UserAddressRelation are fully loaded .
Code:
List<UserAddressRelation> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.setFetchMode("address",FetchMode.JOIN)
.list();


The same result for:
Query 1:
List of proxied addresses is returned.
Code:
List<Address> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.createAlias("address","a",Criteria.INNER_JOIN)
  .setProjection(Projections.property("address")
.list();


Query 2:
Addresses inside UserAddressRelation are not proxied.
Code:
List<UserAddressRelation> addresses = criteria.forClass(UserAddressRelation.class)
.add(Restrictions.eq("user",someUser))
.createAlias("address","a",Criteria.INNER_JOIN)
.list();

_________________
Dencel
- The sun has never seen a shadow -


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.