-->
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.  [ 4 posts ] 
Author Message
 Post subject: alias problem
PostPosted: Wed Jan 09, 2008 6:48 am 
Newbie

Joined: Mon Jul 24, 2006 6:07 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1.3

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:
oracle 10g

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi all,

When i run my application, this query was generated in hql:
select W.Y.a from X,W where X.Y.s = 55;

The SQL generated for hibernate is:
select y0.a from Y as y0,Y as y1,X as x, W as w where
w.NR_SQ = y0.NR_SQ and x.NR_SQ = y1.NR_SQ and
y1.s = 55.

The hibernate generated 2 alias for the same table, the correct for me would be:
select y.a from Y as y,X as x, W as w where
w.NR_SQ = y.NR_SQ and x.NR_SQ = y.NR_SQ and
y.s = 55.

I compared the results of the queries and they are really different.

How i fix this problem?

Thanks.

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 6:57 am 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
I think X and W are linked (in your mind) but nothing tells it in your HQL query. You may try something like this:

Code:
select W.Y.a from W inner join X where X.Y.s = 55;


Hope it helps...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 1:10 pm 
Newbie

Joined: Mon Jul 24, 2006 6:07 pm
Posts: 4
aec wrote:
I think X and W are linked (in your mind) but nothing tells it in your HQL query. You may try something like this:

Code:
select W.Y.a from W inner join X where X.Y.s = 55;


Hope it helps...


But in my case, W and X are not linked.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 6:36 am 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
OK. In fact nothing tells hibernate that "Y from W is the same than Y from X".
So you must explicitely link the two Ys.

Something like this may work:

select W.Y.a from X,W where W.Y.id=X.Y.id and X.Y.s = 55;


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