-->
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: Problem with insert into ...select query - ambiguous column
PostPosted: Wed Mar 15, 2006 3:04 am 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
Hi,

I am using Hibernate 3.1.1 and annotations beta 8. I am trying to do an insert into select, but I am getting abiguous columns. There is a cross join in my select and it is ignoring the reference to the second table, but the query works fine in oracle.

Here is an example HQL query

insert into c (id, a, b, c) select a.id, a.a, a.b, c.c
from aa as a, bb as b
where a.a=b.a and a.b=b.b

the generated query looks like this

insert into cc (id, a, b, c) select a.id, a.a, a.b, c.c
from aa as a, bb as b
where a=a and b=b.

As you can see, hibernate strips the table alias from the where clause. The columns a=a and b=b are ambiguous. Does anyone know how to remedy this? Is this a bug?

The classes/tables have no reference to each other in the mapping files.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 2:34 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
The same query works fine in hibernate without the insert into. So,

select a.id, a.a, a.b, c.c from aa as a, bb as b where a.a=b.a and a.b=b.b

works fine. The reference doc states that select into should work for any select statement, so I think this is a bug. I am going to test if using a join gets around the issue.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.