Hi,
I have two entities
A and
B with a many-to-many relation. The relation has an attribute
ATTRIBUTE of type
Integer.
These entities represented by three tables on the DB level.
Table
TAB_A with primary
ID_A corresponds to the entity
A.
Table
TAB_B with primary
ID_B corresponds to the entity
B.
Table
TAB_A_B with composite primary key
(ID_A,ID_B) and a field
ATTRIBUTE for the attribute of the relation represents the relation.
On the Java level I would like to get only two classes
ClassA for the entity
A and
ClassB for the entity
B.
ClassA has an attribute
Map<ClassB,Integer> mapBs for the relation.
I tried
Code:
@ElementCollection
@CollectionTable(name="TAB_A_B",joinColumns=@JoinColumn(name="ID_A"))
@Column(name="ATTRIBUTE")
@MapKeyJoinColumn(name="ID_B", referencedColumnName="ID_B")
private Map<ClassB,Integer> mapBs
But Hibernate generated SQL
Code:
select
ID_A,
ATTRIBUTE,
TAB_A_B _KEY
from
TAB_A_B
where
ID_A=?
and told me that
Code:
column TAB_A_B _KEY does not exist
.
So the question is as follows.
Is it possible to force Hibernate to make only two classes with an map attribute?
And how if the answer is yes.
Thank you in advance,