Hi guys,
I'm new to Hibernate, and using Hibernate 3.2.3.
I have a simple domain object -- bo.User, and a Hibernate config file as shown as follows,
Code:
<hibernate-mapping>
<class name="bo.User" table="user">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="name" column="name" type="java.lang.String"/>
<property name="age" column="age" type="java.lang.Integer"/>
</class>
</hibernate-mapping>
bo.User just has three fields: id, name and age.
I created an User instance by the following codes:
Code:
User user = new User();
user.setId(100);
user.setName("Sha Jiang");
user.setAge(26);
and took advantage of
Code:
Session.save(user);
to insert the data into
user table (I'm using MySQL 5.0.27).
All was OK while running the application.
Then I checked the table, and found that the value of field id wasn't 100, but 1.
It seems that Hibernate ignores values of
incremented id, is it right?
DBMS allows to set value of incremented id explicitly, why Hibernate doesn't?
a cup of Java, cheers!
Sha Jiang