[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4939) Bidirectional OneToOne mapping with FK and composite PK sharing a column throws MappingException

Chris Wilson (JIRA) noreply at atlassian.com
Fri Feb 19 10:07:47 EST 2010


Bidirectional OneToOne mapping with FK and composite PK sharing a column throws MappingException
------------------------------------------------------------------------------------------------

                 Key: HHH-4939
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4939
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.3.2
            Reporter: Chris Wilson
         Attachments: HibernateAnnotationMappingOneToOneTest.java

A bidirectional one-to-one mapping, where the owning side's column is part of a composite primary key, fails to configure, possibly because OneToOneType#getColumnSpan returns zero instead of the actual number of columns used by the join.

When the foreign key column used is not also part of the primary key, or the composite primary key contains only a single column, then the mapping doesn't fail.

{code}
org.hibernate.MappingException: broken column mapping for: journeyComment.id of: org.wfp.rita.test.hibernate.HibernateAnnotationMappingOneToOneTest$Journey
    at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:143)
    at org.hibernate.persister.entity.AbstractPropertyMapping.initIdentifierPropertyPaths(AbstractPropertyMapping.java:206)
    at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:181)
    at org.hibernate.persister.entity.AbstractEntityPersister.initOrdinaryPropertyPaths(AbstractEntityPersister.java:1725)
    at org.hibernate.persister.entity.AbstractEntityPersister.initPropertyPaths(AbstractEntityPersister.java:1755)
    at org.hibernate.persister.entity.AbstractEntityPersister.postConstruct(AbstractEntityPersister.java:2932)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:431)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
    at org.wfp.rita.test.base.HibernateTestBase.buildSessionFactory(HibernateTestBase.java:93)
    at org.wfp.rita.test.base.HibernateTestBase.setUp(HibernateTestBase.java:106)
    at junit.framework.TestCase.runBare(TestCase.java:128)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
{code}

Test case attached. Change HibernateTestBase to org.hibernate.test.annotations.TestCase to run under Hibernate.

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