Hibernate version: 2.1.6
Mysql 4.0.x
consider the following table 'machine', where id_machine is autoincrement.
Code:
id_machine, name, description, platform
1 s1 desc1 fedora1
2 s2 desc2 fedora2
The relevant part of the mapping in the hbm file looks like this.
Code:
...
<id name="idMachine"
column="id_machine"
type="long">
<generator class="increment"></generator>
</id>
...
* Consider 2 different sessions on different machines trying to insert into the table at the same time, the auto increment logic would get the value '3' for both the sessions.
* When tried to commit, only the first session succeeds while the other failes with net.sf.hibernate.exception.ConstraintViolationException.
Is there a way to avoid this?
Thanks for the great tool.
- Vinay