Bug 111 : ORA-00918: column ambiguously defined ... when using a max rows or first rows limit on Oracle
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
1.2.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
07/05/2009
Updated 
07/05/2009
Type 
Bug
 
Attachments 
No attachments

refer to topic http://www.avaje.org/topic-144.html

SQL> ;
1 select * from (
2 select a.id, b.id
3 from my_p a
4 join my_person b on b.id = a.id
5* )
SQL> /
select * from (
*
ERROR at line 1:
ORA-00918: column ambiguously defined

 
Rob 07 May 11:21
Solution: always have a column alias

The solution will be to always have a column alias EXCEPT for subQueries.

That is if you use the in subQuery expression on the where clause Ebean will not add column alias for the subQuery columns.

Query subQuery = Ebean.createQuery(Product.class)
.select("id").where().idEq(4).query();

List list = Ebean.find(MinCustomer.class)
.where().in("id", subQuery).findList();

Rob 07 May 11:22
Resulting SQL:

select c.id c0, c.name c1, c.notes c2
from o_customer c
where (c.id) in (select p.id from o_product p where p.id = ? )

Rob 08 May 07:07
Fixed in HEAD

Ebean will always include a column alias except for sub queries.

woResponse

Upload a file