-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: "Empty" PersistenceContext during Lazy Loading
PostPosted: Tue Oct 13, 2009 4:58 am 
Newbie

Joined: Mon Aug 03, 2009 9:16 am
Posts: 2
Hi to all!

I'm implementing Remote Lazy Loading in my client/server application. The server part is powered by the combination of OSGi, Hibernate and Spring.

I've followed the following examples to implement this mechanism
http://www.theserverside.com/tt/articles/article.tss?l=RemoteLazyLoadinginHibernate
https://www.hibernate.org/377.html?cmd=prntdoc

The problem is that when I invoke the remote service, I use the following code which throws the indicated exception.
Code:
return getHibernateTemplate().execute(new HibernateCallback() {
   public Object doInHibernate(Session session) throws HibernateException, SQLException {
      CollectionPersister persister = ((SessionFactoryImplementor) getHibernateTemplate().getSessionFactory())
            .getCollectionPersister(role);
      CollectionKey key = new CollectionKey(persister, id, EntityMode.POJO);

      PersistenceContext context = ((SessionImplementor) getSession()).getPersistenceContext();
      T wrapper = (T) context.getCollection(key);

      if (wrapper == null) {
         throw new IllegalStateException("Collection not found");
      }

      return wrapper.unwrapp();
   }
});


The problem here is that PersistenceContext has absolutely NO information about entity or collection entries and I therefore returns "null". Can somebody give me a hint how to "initialize" the persistence context?

Best regards,
Daniel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.