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=RemoteLazyLoadinginHibernatehttps://www.hibernate.org/377.html?cmd=prntdocThe 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