david wrote:
Try nulling the id. Assuming your not using 'assigned' generator then a new Id will be assigned and a new tuple created.
I've tried that wil code like:
ClassMetadata snapshotMeta =sessionFactory.getClassMetadata(newSnapshot.getClass());
snapshotMeta.setIdentifier(newSnapshot, null);
And when the code runs, I get an exception like:
[java] java.lang.IllegalArgumentException
[java] at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45)
[java] at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:287)
[java] at SOpen.common.dao.VDAORoot.newifySnapshot(VDAORoot.java:145)
[java] at SOpen.common.dao.VDAORoot.recordSnapshot(VDAORoot.java:214)
[java] at local.gerry.SPMTest.main(SPMTest.java:80)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:208)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:150)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:443)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:163)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at org.apache.tools.ant.Task.perform(Task.java:341)
[java] at org.apache.tools.ant.Target.execute(Target.java:309)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:609)
[java] at org.apache.tools.ant.Main.start(Main.java:196)
[java] at org.apache.tools.ant.Main.main(Main.java:235)
[java] rethrown as
[java] net.sf.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of SOpen.common.dao.DAOBase.primaryKey
[java] at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:64)
[java] at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:287)
[java] at SOpen.common.dao.VDAORoot.newifySnapshot(VDAORoot.java:145)
[java] at SOpen.common.dao.VDAORoot.recordSnapshot(VDAORoot.java:214)
which has thrown me a bit (and what started my windmill tilting session :-)
Gerry