How is entities comparison (equality) statement evaluated in JPQL: is it by identity comparison, or by equals(), or sth else?
I've spent a couple of hours of googling and going through the specs of Hibernate and JPA but still can't find how it works. Consider the following entities:
class MyProductType{Integer id;}
class MyProduct{Integer id; MyProductType pType;}
And now the JPQL/HQL query:
SELECT t FROM MyProductType t, MyProduct p WHERE p.pType = t
(I know it's an ugly query, just focus on the where clause semantics.)
So how is p.pType = t evaluated?
JSR 317 mentions "entity_expression" comparison but it's behaviour is not clarified.
EDIT: What I dislike about Rika's suggestion below is that the .id approach includes implicit inner join which is usually not what you want in case the query employs an OUTER (LEFT) join.