[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-1115) Problem in "one-to-zero-or-one" relationship

Steve Ebersole (JIRA) noreply at atlassian.com
Mon Mar 21 13:00:58 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-1115.
-------------------------------


Closing stale resolved issues

> Problem in "one-to-zero-or-one" relationship
> --------------------------------------------
>
>                 Key: HHH-1115
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1115
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.1 rc2
>         Environment: Linux 2.6.11-kanotix-7
>            Reporter: Regis Pires Magalhaes
>
> I've mapped a "one-to-zero-or-one" relationship as explained below:
> Association: Person [1 <--> 0..1] Note
> Mapping documents:
> <hibernate-mapping>
>    <class name="Person" table="person">
>       <id name="id" column="id" type="int" unsaved-value="-1">
>           <generator class="sequence">
>               <param name="sequence">person_id_seq</param>
>           </generator>
>       </id>
>       <property name="name" type="string"/>
>       <many-to-one name="note" class="Note" column="id"
>                    unique="true" insert="false" update="false"
>                    cascade="all"/>
>    </class>
>    <class name="Note" table="note">
>       <id name="id" column="id" type="int" unsaved-value="-1" >
>           <generator class="foreign">
>               <param name="property">owner</param>
>           </generator>
>       </id>
>       <property name="note" type="string"/>
>       <one-to-one name="owner" class="Person" constrained="true"/>
>    </class>
>    
>     <query name="personFindById">
>       select person from Person person
>          left join fetch person.note
>       where person.id = :id
>     </query>
> </hibernate-mapping>
> Query:
> select person from Person person
>    left join fetch person.note
> where person.id = :id
> The generated SQL (show_sql=true):
> select person0_.id as id5_0_,
>      note1_.id as id6_1_,
>      person0_.name as name5_0_,
>      note1_.note as note6_1_
> from person person0_
> left outer join note note1_ on person0_.id=note1_.id
> where person0_.id=?
> PostgreSQL SQL Result:
>  id5_0_ | id6_1_ | name5_0_ | note6_1_
> --------+--------+----------+----------
>       1 |        | Regis    |
> (1 row)
> Name and version of the database: PortgreSQL 8.0.3
> When I excute the query all persons that do not have a matching note should have a null note, but a note proxy is returned by Hibernate. The generated sql does the left join but the 'initialized' property in proxy (org.hibernate.proxy.CGLIBLazyInitializer) is set to 'false'. That shouldn't be happening, isn't it? Note should be null.

-- 
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