I was using auto sequence to generate id before:
<id type="java.lang.Integer" unsaved-value="null" name="id">
<generator class="native"/>
</id>
now I switched to assigned id:
<id type="java.lang.String" name="id">
<generator class="assigned"/>
</id>
In the documentation, it says:
Choosing the assigned generator makes Hibernate use unsaved-value="undefined", forcing Hibernate to go to the database to determine if an instance is transient or detached, unless there is a version or timestamp property, or you define Interceptor.isUnsaved().
What exactly this means? Is there any efficiency problem using assigned id? If yes, how can I use version or define Interceptor.isUnsaved()?
A side effect after I made the change:
if I insert object with the same id twice (restart transaction in between), no
DataIntegrityViolationException is thrown? How come?
|