I\'m using hibernate 4+.
I have two sample tables.
Table A
public class A {
@Id
private int id;
@OneToMany(fetch=LAZY)
private List&
You can define two fields in B, one representing the relationship, and the other just the column:
@ManyToOne(fetch=LAZY)
@JoinColumn(name="b_id")
private A a;
@Column(name="b_id", updatable=false,insertable=false) //Or correct column
private int a_id;
This way you can access entity A or just A's id from entity B.