-->
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: Ambiguous column problem with the query fo extended objects.
PostPosted: Fri May 06, 2005 6:21 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:59 am
Posts: 47
Location: Gurgaon, India
Hi,

We have working with a number of dataobjects which are lying in multilevel inheritence hierarchy. Object's hierarchy is like,

BasicObject < ServerObject < Folder < AObject

All the objects do have 'OBJECT_ID' field with it.

Now if I want to fire a query on 'basic object' table, like

from ServerObject where OBJECT_ID = 1

We are getting an invalid query exception stating that OBJECT_ID column is ambiguous (Because it presents in both tables i.e. in ServerObject as well as in BasicObject).

Query formed by hibernate is:

select serverObj0_.OBJECT_ID as OBJECT_ID, serverobj0_.NAME as NAME1_, serverobj0_1_.VERSION as VERSION from ServerObject serverobj0_ inner join BasicObject serverobj0_1_ on serverobj0_.OBJECT_ID = serverobject0_1_.OBJECT_ID where (OBJECT_ID=1)

This problem can be avoid by manipulating the query a little, like

from ServerObject as s where s.OBJECT_ID = 1

i.e. by providing Alias in the query. But
is there any way to get this work done without aliases?
can Hibernate handle this alias problem itself?

Thanks
Mohit.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 11:08 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:59 am
Posts: 47
Location: Gurgaon, India
We are waiting for any suggestion. Please tell us, should we elaborate the query?


Top
 Profile  
 
 Post subject: Re: Ambiguous column problem with the query fo extended obje
PostPosted: Thu May 12, 2005 4:57 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
mohitgupta_india wrote:
from ServerObject as s where s.OBJECT_ID = 1


This is the correct way to do it through Hibernate unless you use native SQL queries. Perhaps I misunderstand your question.


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.