Results 1 to 2 of 2

Thread: Spring with Hessian and Hibernate LazyLoading

  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Unhappy Spring with Hessian and Hibernate LazyLoading

    Hi,

    During my school-project i like to have access from a Client (javaFx) to a Serverapplication (Tomcat 6) with Spring as framework. But now, on the persistence Layer i've got the problem by Loading Entity with OneToMany-Relations over my defined Services. i've try to get a Entity over Hessian call. But actually i get the error:

    Code:
    2010-05-02 16:23:49,548 [main] ERROR - failed to lazily initialize a collection, no session or session was closed
    0org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
    	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
    My Service Export in applicationcontext.xml look like this:
    Code:
    <bean id="customerHessianService" class="org.springframework.remoting.caucho.HessianServiceExporter"> 
           <property name="service" ref="customerService" />
           <property name="serviceInterface" value="Application.Sale.Service.ICustomerService" />
    The dispatcher-servlet.xml look like this:
    Code:
    <bean id="urlMapping" 
    	  class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>           
                    <prop key="/calculationBP.service">calcalutionBusinessSercvice</prop>
    The Entity has a OneToMany Relation with the follow JPA Annotations:
    Code:
    @OneToMany(fetch = FetchType.EAGER, targetEntity = Item.class, mappedBy = "_itemHeadId", cascade = { CascadeType.REMOVE })
    	private Collection<Item> _headItems = new HashSet<Item>();
    When i debug the Server side i can see that my Annotation - fetch=FechtType=EAGER works, i have all the child entities when i call getChilds() methode on EntityPojo. But when Hessian try to call method com.caucho.hessian.io.HessianInput.readObject() i get the "LazyInitializationException".
    I don't understand why hessian makes the load of child entities twice? there are already in collection on EntityPojo or isn't it?

    Could anyone say me a way to solve this problem? Thanks for Help.

    cheers,

    lumpiscore

  2. #2
    Join Date
    Nov 2005
    Posts
    5

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •