[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3854) Issue with greedy loading of associations (default-lazy=false )

HG (JIRA) noreply at atlassian.com
Thu Dec 29 10:35:19 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3854?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44772#comment-44772 ] 

HG commented on HHH-3854:
-------------------------

@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)

With the Patch @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) does not works.

As mentioned in the envers docs,

"If you want to audit a relation, where the target entity is not audited (that is the case for example with dictionary-like entities, which don't change and don't have to be audited), just annotate it with @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED). Then, when reading historic versions of your entity, the relation will always point to the "current" related entity"

The above is not the behaviour, It behaves as if the relationship is audited. Hence, when reading historic versions of your entity, the relation will always point to the entity at the version in question.

But If you are using auditing, then it is not the problem, and everything else works fine :)

> Issue with greedy loading of associations (default-lazy=false )
> ---------------------------------------------------------------
>
>                 Key: HHH-3854
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3854
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: envers
>         Environment: Hibernate - core 3.4.0-SNAPSHOT, Hibernate-envers (from trunk)
>            Reporter: Amar Singh
>            Assignee: Erik-Berndt Scheper
>         Attachments: envers-HHH-3854-testcases.patch, greedy-loading.zip
>
>
> I have an Entity GP which has a many to one association to entity CA.
> <?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="native"/>
>   </id>
>   <property name="data"/>
>   <many-to-one name="reference" cascade="save-update" class="BidirectionalRefEdPK" column="BIDIRECTIONAL_REFERENCED_ID"/>
>  </class>
>  
>  <class name="BidirectionalRefEdPK" table="BIDIRECTIONAL_REFERENCED_ENTITY">
>   <id name="longId" type="long" column="BIDIRECTIONAL_REFERENCED_ID">
>    <generator class="native"/>
>   </id>
>   <property name="data"/>
>  </class>
>  
> </hibernate-mapping>
> With this when I load a previous version of BidirectionalRefIngPK, the loading mechanism tries to create a proxy for BidirectionalRefEdPK, but in my case lazy is false so an internal call to createProxy will return NULL hence .
> This happens in ToOneIdMapper.java in method mapToEntityFromMap around line 82, which then internally calls for AbstractEntityTuplizer.java line 395 for getProxyFactory() ending in NULL pointer exception because proxy factory is null as mine is a greedy loading. 
> TO REPRODUCE
> ~~~~~~~~~~~~~
> Please find a zipped folder attached. The zipped file has 4 files:
> - GreedyLoading.java (actual testng test case)
> - BidirectionalRefEdPK.java (Entity 1)
> - BidirectionalRefIngPK.java (Entity 2)
> - greedyloading.hbm.xml
> Please place the three java files in its package (org.hibernate.envers.test.integration.onetoone.bidirectional), couldn't find the right package so created test case accordingly. Put the greedyloading.hbm.xml in src/test/resources.
> Now when testng runs GreedyLoading.java you should see NPE.

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