-->
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.  [ 2 posts ] 
Author Message
 Post subject: What is the difference between two queries?
PostPosted: Mon Jan 29, 2007 7:04 pm 
Newbie

Joined: Wed Oct 18, 2006 9:39 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

Hi,

I'm little bit confused. So pardon me if it sounds stupid.

a) Consider two table Order, LineItem. Lineitem table has reference to order_id.

class LineitemBO{
}
Class OrderBO{
Set lineitems;
.....
}

b) Assume *.hbm files are written for those tables and there is a one to many relation between order and lineitem. The entities are marked "lazy" and made to use outer join

c) Insert an order with 3 lineitems whose order_id=10 (say)

d) Do OrderDAO.load(OrderId=10), which creates one OrderBO with 3 lineitems in the set as a result of association


e) Run the same query using HQL
(ie) Criteria.add(Expression.eq("orderid",10));
The returned collection is going to have 3 orderbo objects having the same identity.

I expected HQL result should be same as that of session.load(...). Am I missing something?

regards,
Haneef


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 29, 2007 7:22 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Code:
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.