Answer the question
In order to leave comments, you need to log in
How does @OneToMany-Hibernate binding happen?
The question is this.
There is a User entity
@Entity
@Table(name="USER_DETAILS")
public class UserDetails {
@Id
private int id;
@OneToMany(mappedBy="user")
private Collection<Vehicle> vehicles = new ArrayList();
}
@Entity
public class Vehicle {
@Id
private int id;
@ManyToOne
@JoinColumn(name="USER_ID")
private UserDetails user;
}
Answer the question
In order to leave comments, you need to log in
Your UserDetails class has an @Id annotation over the variable, and it defines it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question