This content has been marked as final.
Show 2 replies
-
1. Re: Setting the ID of the entity manually before persist
whafrog Aug 9, 2007 10:07 AM (in response to trouby)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. -
2. Re: Setting the ID of the entity manually before persist
trouby Aug 9, 2007 12:40 PM (in response to trouby)Ye, I figured it out,
I just need it for initial data, and I wanted to keep the IDs synchronized,
Well, thanks :)
Asaf