This content has been marked as final. Show 2 replies
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.
Ye, I figured it out,
I just need it for initial data, and I wanted to keep the IDs synchronized,
Well, thanks :)