I am using hibernate 4+.
I have two example tables.
Table a
public class A {
@Id
private int id;
@OneToMany(fetch=LAZY)
private List<B> list;
}
Table B
public class B {
@Id
private int id;
@ManyToOne(fetch=LAZY)
@JoinColumn(name="b_id")
private A a;
}
Table A (1) - (n) Table B Relation
Is it possible to simply get the identifier in object B not using a connection?
like int help = b.getA (). getId (); // b is an instance of B;
Although I can use the int value instead of A when I declare a class B. But another service level uses A with join.
Is it possible to simply get the id (fk) value?
Please, help.
source
share