-->
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 query select specific columns from sevaral entities
PostPosted: Thu Jul 25, 2013 8:51 am 
Newbie

Joined: Thu Jul 25, 2013 8:36 am
Posts: 1
Hi,
I have an entity A, which has entity B and B has entity C : A -> B -> (collection of C)
I want to form a criteria query and select all columns from A, all columns from B and specific columns from C.
I wrote a query using Criteria and Projections, but its querying only the specified columns of entity C and none from A or B.

Here is my query :
Criteria crit = s.createCriteria(A.class, "tableA")
.add(Restrictions.eq("Id", 100))
.createAlias("b", "tableB")
.createAlias("tableB.c", "tableC");

ProjectionList proList = Projections.projectionList();
proList.add(Projections.property("tableC.prop1"));
proList.add(Projections.property("tableC.prop2"));
proList.add(Projections.property("tableC.prop3"));
crit.setProjection(proList);
crit.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);

Can somebody tell me how can I tune this query ?
Thanks much in advance.


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.