I have a class Posting with an @Embedded:
{code} public class Posting { @Embedded private BankDetails bankDetails; }
public class BankDetails { private String bankCode; private String bankName; } {code}
Now I want to list all Postings with a bankCode of 123 and a bankName of null.
{code} Query q = entityManager.createQuery("SELECT o from Posting o WHERE bankDetails=?"); q.setParameter(1, new BankDetails("123", null)); {code} However I don't get any results.
Why?
Here's the sql query Hibernate executes:
{code} select posting0_.bank_code as bank_cod6_42_, posting0_.bank_name as bank_nam7_42_ from posting posting0_ where (posting0_.bank_code, posting0_.bank_name)=('123', null) {code} That obviously does not work because it compares * null * with * = * .
Original question on SO: http://stackoverflow.com/questions/38206913/hibernate-where-does-not-work-for-embedded-with-null-member |
|