views:

59

answers:

1

Hi, guys,

I'm coding a web page in Hibernate-JPA and Oracle.

I need the following:

I have two classes: Place and Home.

I need two collections of type Place in every Home: I do the following:

Home:

@ManyToOne
@JoinColumn(name="ID_PLACES")
private List<Places>places1;

@ManyToOne
@JoinColumn(name="ID_PLACES")
private List<Places>Places2;

However, hibernate got an exception (repeated column) and forces to me to mapping with insert and update to false.

How Can I get Two ManyToOne relationship to same primary key with insert a true?.

A: 

Yeah, but in other side, I must put:

@ManyToOne @JoinColumn(name="ID_PLACES") private Place place1;

@ManyToOne @JoinColumn(name="ID_PLACES") private Place place2;

isn't it?. There is my error: related to same primary key.

Thanks for your quick response, of course.

ethiel
On the other side you would have `private Home home1` if you want the association to be bi-directional (btw, please edit and update your question with this comment as it is not an answer; then delete this answer).
Pascal Thivent