0 Replies Latest reply on Sep 16, 2014 11:25 AM by stefano81

    JBoss 7.1.1 + hibernate.ejb.use_class_enhancer (Lazy 1-to-0-or-1 relationships)

    stefano81

      Hello,


      As you know, lazy loading of inverse (not owning) optional one-to-one relationships using Hibernate does not work out of the box.

      Hibernate does not know if a proxy object or NULL must be used, so the loading occurs before the field is accessed for the first time (NOT LAZY).

       

      There are some solutions for this problem (also known as shared PK one-to-zero-or-one), and I need to use the one that involves runtime bytecode instrumentation. It requires Hibernate as JPA provider in full-blown JEE environment (I am using JBoss 7.1.1), setting "hibernate.ejb.use_class_enhancer" to true.

       

      So, following Table 2.1 in Chapter 2. Setup and configuration I added the following line to persistence.xml:

      <property name="hibernate.ejb.use_class_enhancer" value="true" />

       

      The application works fine (no errors), BUT nothing changes (Hibernate still runs thousands of queries). My goal is to load the optional onetoone relationship only when the value is needed, because the eager loading is giving me performance issues.

       

      Does anyone have any ideas?

       

       

      Thank you,

      S.