Hello,
I have entity model like this (using EclipseLink and JPA 2.0):
@Entity
class A {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
//equals, hashCode autogenerated by nb.
}
And:
@Entity
class B {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
@ManyToOne
A a;
//equals, hashCode autogenerated by nb.
}
I query all objects of type A, and all objects of type B, which have not null reference on B.a field. All objects are managed. For instance, lets take Collection<A> aObjects, Collection<B> bObjects
.
Consider that aObjects.get(0).equals(bObjects.get(0).a)
, and a != null
. How can I ensure that aObjects.get(0) == bObjects.get(0).a
?
I have equal / identical objects, but I would rather prefer the same object.