I have a entity "User", and i just create it and try to persist it, but I got a error message, something like i was persisting a detached Entity.
I checked the code of "User", i found there was no auto generated id property like other entities, the identity is the "name" property, which must be initialed by creating. Then I added the "dummy" id property just like normal, all work fine!
So I just wonder, why JPA/Hibernate said it was a detached Entity at all? I guess, it just checks the identity property of the entity, if it's not NULL (dummy ids are almost always null by creating and will be auto generated), and there is no copy in PersistenceContext with the same identity, then it will be considered as detached?
Am I right? But what about the situation, when i don't want to use the auto generated identity? How can I persist them?