I'm using hibernate 4+.
I have two sample tables.
Table A
public class A {
@Id
private int id;
@OneToMany(fetch=LAZY)
private List<B> list;
// skip getter&setter
}
Table B
public class B {
@Id
private int id;
@ManyToOne(fetch=LAZY)
@JoinColumn(name="b_id")
private A a;
// skip getter&setter
}
Table A(1) - (n)Table B Relation
Can I just get A's id in object B not using join? Something like:
int aid = b.getA().getId(); // b is instance of B;
Although I can use int value instead of A when I declare class B. But another service layer use A with join.
Can I just get id(fk) value?