-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query returning different results
PostPosted: Tue May 18, 2004 2:39 pm 
Newbie

Joined: Mon May 03, 2004 1:08 am
Posts: 18
List list1 = s.createCriteria(Order.class)
.createCriteria("items", "item")
.add( Expression.eq("item.name", "p123") )
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.setMaxResults(5)




List list2 =
s.createQuery(
"from Order order "
" where exists
( from items as item
where item.order = order
and item.name= :name )
)
.setParameter("name", "p123")
.setMaxResults(5)
.list();

Is there a way to make the first query behave like the second?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 5:15 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
yes you can criteria can execute very complexe queries.
But give more details about your question, DB schema, POJO...


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 21, 2004 1:24 pm 
Newbie

Joined: Mon May 03, 2004 1:08 am
Posts: 18
Schema is simple Order and Line like in the Hibernate example chapter.


I want all Orders where Item "Milk" was Ordered.
Let us say in Order1 there are 100 items all of them for Milk.
Similarly Order 2.


When executing the exist query I am guaranteed to get only 1 occurance of Order no matter how many items were Milk.

Executing the criteria query I dont get the same results.


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

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.