1 Reply Latest reply on Jun 7, 2006 8:39 AM by David Budworth

    JBAS 4.0.4 GA and OneToOne lazy relationships

    David Budworth Newbie

      Is it possible to get OneToOne relationships to be lazy initialized?

      Our "main" entity has 12 or so OneToOne relationships that seem to get selected every time.

      We're doing a simbol "from MainClass" query on the entity manager, but when I enable hibernate sql tracing, i see all the related tables get included.

      I've tried turning on "hibernate.bytecode.use_reflection_optimizer=true"
      just in case that was it. Also tried "hibernate.ejb.use_class_enhancer" in persistence.xml, but got class not found exceptions looking for ASM

      We use on our Main class:

      @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
      private ChildObject child;

      Then just plain old:
      public ChildObject getChild(){ return child; }
      public void getChild(ChildObject child){ this.child = child; }

      We have the same issue on objects where the persistence annotations are on the getChild() method. I just recently moved them to the properties since it's much cleaner to have them all together at the top without the noise of the get/set methods between the fields.