Hello all,
I am trying to use hibernateSession.saveOrUpdateCopy to copy objects from one database to another.
Code:
User test = (User) originalSession.load(User.class, new Long(3065));
try {
tx = archivalSession.beginTransaction();
Object copy = archivalSession.saveOrUpdateCopy(test);
tx.commit();
archivalSession.flush();
archivalSession.close();
} catch (HibernateException e) {
logger.warn(e.getMessage(), e);
tx.rollback();
//TODO log error to form
}
I end up getting errors when hibernate tries to access (via reflection or cglib) the getters of the object to be copied:
Code:
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96)
at net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java:242)
at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:3826)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:3780)
I'm guessing that this is a mis-use of the saveOrUpdateCopy call, but it would be REALLY nice if I could archive things in this manner without having to do this in straight sql or traversing the object tree manually.
Any thoughts on why accessing the getters is failing?
Thanks,
Marcus
Code: