-->
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: Upgrading Hibernate 2.1.8 to Hibernate 3.6.10
PostPosted: Fri Dec 19, 2014 7:57 am 
Newbie

Joined: Fri Dec 19, 2014 7:52 am
Posts: 1
We are trying to upgrade a legacy application from Hibernate 2.1.8 to Hibernate 3.6.10. The application uses few classes written using hibernate 2.1.8 api to provide their own persistence mechanism. The problem is that Hibernate 3.6.10 does not have those api's functions anymore and hence we need to rewrite the classes. Can you help us in finding the appropriate matches in hibernate 3 for below :

HibernateProxyHelper.getLazyInitializer((HibernateProxy)object).isUninitialized()

You can see the code below

import java.util.Collection;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.collection.PersistentCollection;
import net.sf.hibernate.proxy.HibernateProxy;
import net.sf.hibernate.proxy.HibernateProxyHelper;
import com.******.component.AbstractComponent;
import com.******.****.persistence.ILazyInitializationProxyStrategy;
import com.******.****.persistence.PersistenceException;

/*
* Initialize Hibernate proxies
*/
public class HibernateLazyInitializationProxyStrategy extends AbstractComponent
implements ILazyInitializationProxyStrategy {

/**
* @return is the object an uninitialized hibernate proxy
*/
public boolean isProxy(Object object) {
return isObjectProxy(object) || isCollectionProxy(object);
}


public boolean isObjectProxy(Object object) {
return object instanceof HibernateProxy && HibernateProxyHelper.getLazyInitializer((HibernateProxy)object).isUninitialized();
}


public boolean isCollectionProxy(Object object) {
return object instanceof PersistentCollection && !((PersistentCollection)object).wasInitialized();
}
public Object initializeProxy(Object object) throws PersistenceException{
Object returnValue = object;
if (object instanceof HibernateProxy) {
try {
if (HibernateProxyHelper.getLazyInitializer((HibernateProxy)object).isUninitialized()) {
HibernateProxyHelper.getLazyInitializer((HibernateProxy)object).initialize();
}
returnValue = HibernateProxyHelper.getLazyInitializer((HibernateProxy)object).getImplementation();
} catch (HibernateException e) {
// TODO Auto-generated catch block
throw new PersistenceException(e);
}
} else if(isCollectionProxy(object)) {
((Collection)object).size();
}
return returnValue;
}


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.