[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2158) incorrect hql query on one-to-one with property-ref

Cyrille Karmann (JIRA) noreply at atlassian.com
Tue Sep 15 12:19:52 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33968#action_33968 ] 

Cyrille Karmann commented on HHH-2158:
--------------------------------------

Hi all, I have run into this problem and I think that after a fey days on it, I found a quite easy workaround. Instead of using "is null", it seems "is empty" should be used, as if it was a collection.
So instead of:
select master from Master master where master.slave2 is null
use
select master from Master master where master.slave2 is empty

This is quite illogical, but it works like this. This behavior should at least be documented, I think.

> incorrect hql query on one-to-one with property-ref 
> ----------------------------------------------------
>
>                 Key: HHH-2158
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2158
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.0.ga
>         Environment: hibernate 3.2.0.ga with firebird 1.5.3 and jaybird 1.5.5 driver on windows XP
>            Reporter: Sebastien Cesbron
>         Attachments: testhib.zip
>
>
> I have a one-to-one relationship with property-ref between Master and Slave2.
> I want to find all Master instances that have a null Slave2 instance associated.
> To do so my query is
> select master from Master master where master.slave2 is null
> The sql generated is
> select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_ where master0_.oid is null
> which seems incorrect. It checks here Master instances with null id (config files are listed below).
> If I do my query like this
> select master from Master master where master.slave2.oid is null
> the generated sql is ok :
> select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_, Slave2 slave2x1_ where master0_.oid=slave2x1_.myMaster and (slave2x1_.oid is null)
> I have attached a small eclipse project that reproduces the problem
> This problem may-be related to the one I have submitted as issue HHH-1849

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list