[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-3853) one-to-one mapping doesn support Primary Key Association
Lukasz Antoniak (JIRA)
noreply at atlassian.com
Sat Jan 28 12:00:13 EST 2012
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3853?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Antoniak resolved HHH-3853.
----------------------------------
Resolution: Fixed
Fix Version/s: 4.1.0
Assignee: Lukasz Antoniak (was: Adam Warski)
This issue has been solved together with HHH-6825 by applying pull request https://github.com/hibernate/hibernate-orm/pull/246.
> one-to-one mapping doesn support Primary Key Association
> --------------------------------------------------------
>
> Key: HHH-3853
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3853
> Project: Hibernate ORM
> Issue Type: Bug
> Components: envers
> Environment: Hibernate - core 3.4.0-SNAPSHOT, Hibernate - envers (trunk build from today)
> Reporter: Amar Singh
> Assignee: Lukasz Antoniak
> Fix For: 4.1.0
>
> Attachments: hibernate-envers-pkjc.patch, one-to-one-pk.zip
>
>
> one-to-one mapping with primary key association doesn't seem to be working. Eg.
> Code:
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping package="org.hibernate.envers.test.integration.onetoone.bidirectional" default-lazy="false">
> <class name="BidirectionalRefIngPK" table="BIDIRECTIONAL_REFERENCING_ENTITY">
> <id name="id" type="long" column="BIDIRECTIONAL_REFERENCING_ID" >
> <generator class="foreign">
> <param name="property">reference</param>
> </generator>
> </id>
> <property name="data"/>
> <property column="BIDIRECTIONAL_REFERENCING_ID" generated="never" insert="false" lazy="false" name="id" type="long" update="false"/>
> <one-to-one name="reference" cascade="save-update" class="BidirectionalRefEdPK" constrained="true" />
> </class>
>
> <class name="BidirectionalRefEdPK" table="BIDIRECTIONAL_REFERENCED_ENTITY">
> <id name="longId" type="long" column="BIDIRECTIONAL_REFERENCED_ID">
> <generator class="native"/>
> </id>
> <property name="data"/>
> <one-to-one name="referencing" cascade="all" class="BidirectionalRefIngPK" />
> </class>
> </hibernate-mapping>
> When we try to load a BidirectionalRefIngPK, the underlying query invokes RelatedAuditExpression and since its not a foreign-key based one-to-one association the loading fails in method addToQuery of RelatedAuditExpression at line 52 (relatedEntity==null) with the following exception:
> Code:
> "This criterion can only be used on a property that is a relation to another property."
> TO REPRODUCE
> ~~~~~~~~~~~~~
> Please find a zip file attached which has four files:
> - BidirectionalPrimaryAssociation.java (actual testng test case)
> - BidirectionalRefEdPK.java (Entity 1)
> - BidirectionalRefIngPK.java (Entity 2)
> - mappings.hbm.xml
> Please put the three java files in its package (org.hibernate.envers.test.integration.onetoone.bidirectional) and the mapping file in src/test/resources.
> Now when you run envers tests you should see the failure.
> Thanks for this great component !
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list