2 Replies Latest reply on Apr 26, 2012 1:51 AM by Adam Warski

    Why is HHH-3854 (NPE, lazy=false, Apr 2008) unresolved?

    Douglas Fisher Newbie

      Do a search in this forum and you'll find 5 separate posts regarding HHH-3854, several of which Adam has responded to.


      It looks like the answer/story goes like this:


      * It is a known defect.

      * Until we fix it, you can patch Hibernate Envers yourself.


      I am using 3.6.0. In my scenario:


      * I have Entity A, audited in a many-to-one with Entity B, not audited.

      * Entity B is marked lazy=false in the class element of its hibernate-mapping.

      * The many-to-one is marked lazy=false in the hbm file for Entity A.

      * In Entity A, the getter for Entity B is annotated with @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED).

      * I try to list() a RevisionsOfEntityQuery where the only additional criterion is to match the value of a String field (our external-facing entity ID).


      In looking at ToOneIdMapper, it simply looks like the code insists on discovering a proxy-able Entity B (for one of two reasons: either it expects that Entity B is proxied (lazy=proxy or lazy=no-proxy), or it expects that Entity B is audited, because if Entity B is autided it will alsways be proxied by proxyFactory=DynamicMapFactory.)


      * It detects RelationTargetAuditMode.NOT_AUDITED.

      * Therefore it would be a contradiction for it to also expect proxyFactory=DynamicMapFactory.


      Therefore it must be that the code simply doesn't support lazy=false (on either or both of "class" or "many-to-one").


      Looking forward to a response. In the meantime, I'll be trying to figure out if I should go the route of changing our lazy loading configuration, or patching our Hibernate JAR.