1

I have the ID of my table set to autoincrement in MySql 5.1

How do I map my Hibernate with autoincrements set in DBMS?

I tried this way :

<id name="id" type="int" column="ID" >
<generator class="assigned"/>
</id>

Though it doesn't show any error, it does not add anything. Thanks in advance.

mihsathe
  • 8,904
  • 12
  • 38
  • 54

2 Answers2

4

Try

<id name="id" type="int" column="ID" >
    <generator class="native"/>
</id>
javanna
  • 59,145
  • 14
  • 144
  • 125
Swaranga Sarma
  • 13,055
  • 19
  • 60
  • 93
0

you can also try

<id name="id" type="int" column="ID" >
<generator class="identity"/>
</id>

if you are using hibernate to generate ddl (using hibernate.hbm2ddl.auto property set to create or update) the system would generate scripts which would set autoincrement on the id column.

Anantha Sharma
  • 9,920
  • 4
  • 33
  • 35