-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Embeddable null values in JPQL
PostPosted: Fri Oct 15, 2010 8:04 am 
Newbie

Joined: Sat Sep 25, 2010 4:58 am
Posts: 2
Hi everybody,

I have an embeddable class named Sci with 4 String fields, embedded in a Creditor entity.

When I try to find a Creditor using a full Sci object, everything works fine.
Code:
Sci sci = new Sci("FR","98","ZZZ","0123456");
Creditor creditor = new Creditor();
creditor.setSci(sci);
entityManager.persist(creditor);
TypedQuery<Creditor> q = entityManager.createQuery("from Creditor c where c.sci=:sci", Creditor.class);
q.setParameter("sci", sci);
Creditor creditorFromDb = q.getSingleResult();
Assert.assertNotNull("Could not retrieve creditor after insert", creditorFromDb);

But when one of Sci fields is null, the test fails :
Code:
Sci sci = new Sci("FR","98",null,"0123456");
Creditor creditor = new Creditor();
creditor.setSci(sci);
entityManager.persist(creditor);
TypedQuery<Creditor> q = entityManager.createQuery("from Creditor c where c.sci=:sci", Creditor.class);
q.setParameter("sci", sci);
Creditor creditorFromDb = q.getSingleResult();
Assert.assertNotNull("Could not retrieve creditor after insert", creditorFromDb);

If I dump requests on my mysql server, I can see generated request is :
Code:
select  [...] from Creditor creditor0_ where (creditor0_.sci_businesscode, creditor0_.sci_checkdigit, creditor0_.sci_countryiso, creditor0_.sci_nationalidentifier)=(null, '98', 'FR', '0123456') limit 2

The problem comes from '=' operator with null value. It think it should be something like :
Code:
creditor0_.sci_businesscode is null

Is this a normal behavior or a bug ? I cant find anything relevant in JPA specs about this point.

Regards,
Johann


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.