Hi all, I'm trying to do a Many-toMany relationship between two strong tables and one relational table using Hibernate 3.0.
My environment is the following:
Table1
col1 (PK)
col2 (PK)
col3 (PK)
Table2
col4(PK)
Table1_Table2 (This is the relational table just to link Table1 to Table2)
col1 (FK)
col2 (FK)
col3 (FK)
col4 (FK)
Table1VO.java Mapping:
Code:
@OneToMany ( targetEntity = Table2VO.class,
cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY )
@JoinTable(table=@Table(name="Table1_Table2"))
@JoinColumns ({
@JoinColumn(name="col1", referencedColumnName = "col1"),
@JoinColumn(name="col2", referencedColumnName = "col2"),
@JoinColumn(name="col3", referencedColumnName = "col3"),
@JoinColumn(name="col4", referencedColumnName = "col4")
})
When I run my testcase, the select that Hibernate build is the following:
Code:
select table_.TABLE1_col1 as TABLE13_0_,
table_.table2_col2 as table24_0_
from
TABLE1_TABLE2 table_
where
table_.TABLE1_col1=?
What's happen, I don't know why by Hibernate is concating TABLE NAME to the COLUMN NAME, resulting in a Invalid Column Name error.
Could anybody help me?
Best Regards.
Sergio Flor.