How does object comparison work in a JPQL WHERE expression?

How is the essence of comparison (equality) evaluated in JPQL: is it matching identities or equals () or else else?

I spent a couple of hours searching the Internet and went into the Hibernate and JPA specs, but still can't find how it works. Consider the following objects:

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 this is an ugly query, just focus on the semantics of the where clause.)

So how is it estimated p.pType = t?

JSR 317 mentions a comparison of "entity_expression", but the behavior is not specified.

EDIT: I don't like the Rika suggestion below, because the .id approach includes an implicit inner join, which is usually not what you want if the query uses an OUTER (LEFT) join.

+4
2

http://www.objectdb.com/java/jpa/query/jpql/comparison, , .

( ) (=, < > , ==, e1 = e2, e1 e2 , . e1 = e2, e1 e2 .

, . , , p.pType = t, ( , id ) p.pType, t , . , MyProductType.

+3

NetBeans EclipseLink MySQL DB. SQL ( ) .

0

All Articles