Hibernate one to one with multiple columns
Posted
by
Erdem Emekligil
on Stack Overflow
See other posts from Stack Overflow
or by Erdem Emekligil
Published on 2014-06-06T09:23:15Z
Indexed on
2014/06/06
9:24 UTC
Read the original article
Hit count: 194
How can i bind two columns, using @OneToOne annotation?
Lets say I've 2 tables A and B.
Table A:
- id1 (primary key)
- id2 (pk)
- other columns
Table B:
- id1 (pk)
- id2 (pk)
- other columns
In class A i want to write something like this:
@OneToOne(fetch = FetchType.EAGER, targetEntity = B.class)
@JoinColumn(name = "id1 and id2", referencedColumnName = "id1 and id2")
private B b;
Is it possible to do this using annotations?
Thanks.
© Stack Overflow or respective owner