[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3853?page=c...
]
Gail Badner commented on HHH-3853:
----------------------------------
Shawn, you are spot on about when and how core was broken. I'm covering the core fix
in HHH-4982.
Pierrick, does your patch work without the change to core?
one-to-one mapping doesn support Primary Key Association
--------------------------------------------------------
Key: HHH-3853
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3853
Project: Hibernate Core
Issue Type: Bug
Components: envers
Environment: Hibernate - core 3.4.0-SNAPSHOT, Hibernate - envers (trunk build
from today)
Reporter: Amar Singh
Assignee: Adam Warski
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