4 Replies Latest reply on Jan 16, 2006 5:57 AM by Cyril JOUI

    FetchType.LAZY

    daniel jarrett Newbie

      I have an entity called commission that has a property of supplier with the reference to this object set up as below

       @ManyToOne(fetch=FetchType.LAZY)
       @JoinColumn(nullable=false, name="supplier_id")
       public Supplier getSupplier() {
       return supplier;
       }


      I also have a Stateless session bean called PersistenceManager that as you probably guessed manages all the persistence operations for my entity beans.

      Then I have another sesison bean that uses this PersistenceManager to retrieve an instance of the Commission object.

      when I try to get the supplier object attached to this Commission object with

      commission.getSupplier();

      I get the following..

      org.hibernate.LazyInitializationException: could not initialize proxy - no Session


      Any ideas as to why I cannot "get" an attached entity that has a fetch type of LAZY?

      Regards
      Dan