[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: Setting the ID of the entity manually before persist

whafrog do-not-reply at jboss.com
Thu Aug 9 10:07:50 EDT 2007


anonymous wrote : Why is that? The entity is NOT detached, it never got persisted...

Well, you created it with "new", so it's not "attached" to the persistence engine, so it has to be detached...  It's probably not an accurate message.  persist() is for new rows, so it's probably not expecting ID to have a value, assuming that if it does have a value, it must have been previously retrieved.

You've annotated your ID field with @GeneratedValue, so it's all or nothing.  Either remove it and always provide the ID, or keep it and never do.  Mixing the scenarios is a recipe for trouble anyway.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4072529#4072529

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4072529



More information about the jboss-user mailing list