Hibernate: @SecondaryTable causes ORA-00918  
Author Message
ralph





PostPosted: 2008-4-14 22:08:00 Top

java-programmer, Hibernate: @SecondaryTable causes ORA-00918 I have to tables 'first' and 'second':

CREATE TABLE first (
first_id int IDENTITY NOT NULL,
first_value INT NOT NULL,
PRIMARY KEY (first_id)
)

CREATE TABLE second (
second_id int IDENTITY NOT NULL,
first_id int NOT NULL,
second_value INT NOT NULL,
PRIMARY KEY (second_id)
)

I want to join these two tables into one entity using @SecondaryTable.
The columns that are used for joining are named the same in both
tables ('first_id'). Hibernate creates a query like this:

SELECT f_.first_value as first_value_,
s_.secondValue as second_value_
FROM first f_,
second s_
WHERE f_.first_id=s_.first_id(+)
and first_id=?

In the last line Hibernate "forgets" to add a qualifier to 'first_id',
so I get an "ORA-00918: column ambiguously defined" error.

Any ideas?

Thanks,
Ralpe