[hibernate-issues] [Hibernate-JIRA] Créée: (HHH-2076) Bidirectionnal many-to-one with formula and one-to-one doesn't work

Xavier Brénuchon (JIRA) noreply at atlassian.com
Thu Sep 14 09:08:24 EDT 2006


Bidirectionnal many-to-one with formula and one-to-one  doesn't work
--------------------------------------------------------------------

         Key: HHH-2076
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2076
     Project: Hibernate3
        Type: Bug

  Components: core  
    Versions: 3.2.0.cr4    
    Reporter: Xavier Brénuchon
 Attachments: onetoone_bidirectionnal_formula.zip

Hello,


There is a bug with one-to-one association with foreign key associations (doc 5.1.11).
I use composite-id and a formula in many-to-one :

     <class name="Person">
          <composite-id>
               <key-property name="company" type="string" column="COMPANY"/>
               <key-property name="name" type="string" column="NAME"/>
          </composite-id>

          <property name="age" type="int" column="AGE"/>
          
          <many-to-one name="car" class="Car" unique="true">
               <formula>company</formula>
               <column name="FK_CAR_REGISTRATION"/>
          </many-to-one>
     </class>
     
     <class name="Car">
          <composite-id>
               <key-property name="company" type="string" column="COMPANY"/>
               <key-property name="registration" type="string" column="REGISTRATION"/>
          </composite-id>

          <property name="color" type="string" column="COLOR"/>
          <one-to-one name="person" class="Person" property-ref="car"/>
     </class>


I have a problem because Hibernate can't use a formula in the right part of outer join :

DEBUG SQL:393 - 
    select
        this_.COMPANY as COMPANY1_1_,
        this_.REGISTRATION as REGISTRA2_1_1_,
        this_.COLOR as COLOR1_1_,
        person2_.COMPANY as COMPANY0_0_,
        person2_.NAME as NAME0_0_,
        person2_.AGE as AGE0_0_,
        person2_.FK_CAR_REGISTRATION as FK4_0_0_,
        person2_.company as formula0_0_ 
    from
        Car this_ 
    left outer join
        Person person2_ 
            on this_.COMPANY=person2_.null 
            and this_.REGISTRATION=person2_.FK_CAR_REGISTRATION
DEBUG AbstractBatcher:476 - preparing statement
DEBUG JDBCExceptionReporter:63 - could not execute query [select this_.COMPANY as COMPANY1_1_, this_.REGISTRATION as REGISTRA2_1_1_, this_.COLOR as COLOR1_1_, person2_.COMPANY as COMPANY0_0_, person2_.NAME as NAME0_0_, person2_.AGE as AGE0_0_, person2_.FK_CAR_REGISTRATION as FK4_0_0_, person2_.company as formula0_0_ from Car this_ left outer join Person person2_ on this_.COMPANY=person2_.null and this_.REGISTRATION=person2_.FK_CAR_REGISTRATION]
java.sql.SQLException: Column not found: NULL in statement [select this_.COMPANY as COMPANY1_1_, this_.REGISTRATION as REGISTRA2_1_1_, this_.COLOR as COLOR1_1_, person2_.COMPANY as COMPANY0_0_, person2_.NAME as NAME0_0_, person2_.AGE as AGE0_0_, person2_.FK_CAR_REGISTRATION as FK4_0_0_, person2_.company as formula0_0_ from Car this_ left outer join Person person2_ on this_.COMPANY=person2_.null and this_.REGISTRATION=person2_.FK_CAR_REGISTRATION]
	at org.hsqldb.jdbc.Util.throwError(Unknown Source)
	at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
	at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
	at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
	at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415)
	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
	at org.hibernate.loader.Loader.doQuery(Loader.java:661)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
	at org.hibernate.loader.Loader.doList(Loader.java:2144)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
	at org.hibernate.loader.Loader.list(Loader.java:2023)
	at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
	at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
	at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)
	at org.hibernate.test.onetoone.bidirectionnalformula.OneToOneBidirectionalFormulaTest.testReadOneToOneBidirectionalFormula(OneToOneBidirectionalFormulaTest.java:47)


In fact this problem is linked with HHH-944. Soon, I will send a patch which corrects this bug and makes an evolution for HHH-944.


Testcase in onetoone_bidirectionnal_formula.zip :org.hibernate.test.onetoone.bidirectionnalformula.OneToOneBidirectionalFormulaTest




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