I have the following JPQL
query:
@Query("select p FROM Partner p where p.partnerIdentifier IS NOT NULL")
List<Partner> findAfterDates();
This should return all Partner Entities
that DO NOT
have NULL for partnerIdentifier
.
However, I am running the code and debugging, and I am seeing that the returned Collection
contains entities
that has null
for this field.
Is this a bug in JPQL
?
A colleague came by and suggested I use a join
since the inner
object was a one to one
mapped object.
The following now returns correct results:
@Query("select p FROM Partner p join p.partnerIdentifier pi where pi is not null")
List<Partner> findAfterDates();
Once again a reminder that underneath hibernate we have a relational database
and that something that logically should work using oop
/jpql
doesn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With