Results 1 to 5 of 5

Thread: dm Server 2.0 and Hibernate Lazy Loading

Hybrid View

  1. #1

    Default dm Server 2.0 and Hibernate Lazy Loading

    I'm setup so that my web bundle imports @transactional services from a service bundle and a hibernate service factory from a dao bundle. I then use the reference to the servicefactory in an "Open Session in View" filter, and that allows me to access lazily loaded objects in my view. This all worked well in dm Server 1.x, but in dm Server 2.0 I'm getting

    failed to lazily initialize a collection of role: com.spintop.domain.PublisherImpl.hiberContractTerm sSet, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.spintop.domain.PublisherImpl.hiberContractTerm sSet, no session or session was closed

    I'm not even sure which bundle to be looking for problem in.

    Thank you.

  2. #2

    Default

    After looking a little deeper into the problem, I suspect it has something to do with how Spring ORM discovers sessionholders that are bound to the thread. Stepping through TransactionSynchronizationManager.doGetResource(Ob ject actualKey) shows that the actualKey is a SessionFactoryImpl while the key that's stored in the map is a Proxy that points to the same SessionFactoryImpl.

  3. #3

    Default

    Okay, think I've tracked it down. In Spring 3.0's TransactionSynchronizationUtils.unwrapResourceIfNe cessary() method

    Code:
    static Object unwrapResourceIfNecessary(Object resource) {
    		Assert.notNull(resource, "Resource must not be null");
    		Object resourceRef = resource;
    		// unwrap infrastructure proxy
    		if (resourceRef instanceof InfrastructureProxy) {
    			resourceRef = ((InfrastructureProxy) resourceRef).getWrappedObject();
    		}
    		if (aopAvailable) {
    			// now unwrap scoped proxy
    			resourceRef = ScopedProxyUnwrapper.unwrapIfNecessary(resource);
    		}
    		return resourceRef;
    	}
    It's unwrapping the Proxy (InfrastructureProxy), but then if AOP is available, it calls ScopedProxyUnwrapper.unwrapIfNecessary(resource) on the original Proxy and because it's not a ScopedObject, it's overwriting the unwrapped object with the original proxy.

    Edit: I see there is already a JIRA open for this: http://jira.springframework.org/browse/SPR-6625

    Thank you.
    Last edited by kierann; Jan 27th, 2010 at 02:47 PM.

  4. #4

    Default

    I tried using the latest nightly build of spring to get around this, but dm server will not start with spring 3.0.1.CI-xxx in its repository. Something about package conflicts.

  5. #5

    Default

    Working great now with Spring 3.0.2

Posting Permissions

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