Hello,
I have model (simplified version described below) and cannot configure bidirectional association.
Exactly to say — I can access A and B from Bind class (Bind freshly fetched from DB).
But I cannot access Binds neither from A or from B (A and B freshly fetched from DB).
getBindings always returns null though mappedBy properly set.
I tried without EmbeddedId - an it works in both directions.
What is wrong in my config?
Many thanks
Code:
@Entity
class A {
@Id
private Integer id;
@OneToMany(mappedBy = "key.a")
private Collection<Bind> bindings;
}
@Entity
class B {
@Id
private Integer id;
@OneToMany(mappedBy = "key.b")
private Collection<Bind> bindings;
}
@Entity
class Bind {
@EmbeddedId
private BindPK key;
@Basic
private String bindProperty;
}
@Embedded
class BindPK {
@ManyToOne
private A a;
@ManyToOne
private B b;
}