Hi!
I'm trying to compare 2 identical objects in SELECT with no success:
@Embeddable public class PhoneNumber implements Serializable { int countryCode; long number;
Which is a part of Customer object:
@MappedSuperclass @NamedQueries({ @NamedQuery( name="authentication.getByPrincipal", query="SELECT a FROM Customer c WHERE c.principal = :principal" ) }) public abstract class Customer implements Serializable { Object principal;
The entity is:
@Entity public class MobileCustomer extends Customer { @Id @GeneratedValue private Long id; public void setPrincipal(PhoneNumber number){ principal = number; }
And making a query:
Customer customer = em.createNamedQuery("authentication.getByPrincipal", Customer.class) .setParameter("principal", authentication.getPrincipal()).getSingleResult();
According to ObjectDB explorer, the record is stored as expected.
... principal | PhoneNumber | {}
countryCode | int | 123
number | long | 4567890
Then I'm constructing exactly the same object PhoneNumber and passing it to above search query as "principal" and getting "[ObjectDB 2.4.6] javax.persistence.NoResultException" "No matching results for a unique query (error 782)" on getSingleResult
PhoneNumber contains exactly 2 fields. So I'm sure that both objects are same.
What am I doing wrong?
thanks!