Hi, I want to insert record into table by increasing its ID.
The problem that I am facing is when I try to insert the second record, Hibernate will overwrite the existing record in the table.
So below is my mapping xml class.
Course.hbm.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.univ.pojo.Course" table="COURSES">
<id name="courseId" type="integer" column="ID">
<generator class="identity"/>
</id>
<property name="courseName" type="string" column="COURSE_NAME" />
<property name="courseDesc" type="string" column="COURSE_DESC" />
<property name="courseEffectiveDate" type="date" column="COURSE_EFFECTIVE_DATE" />
<property name="courseUniversity" type="string" column="COURSE_UNIVERSITY" />
<property name="courseFee" type="float" column="COURSE_FEE" />
<property name="courseIsDeleted" type="char" column="COURSE_ISDELETED" />
</class>
</hibernate-mapping>
I have tried to use "native", identity", "sequence", "increment", "assigned" as the generator class and none of them is seem to be working...
The column name in my MySQL database is "ID". It is set as NOT NULL, AUTO INCREMENT, PRIMARY KEY, INDEX.
Anyone know how solve this issue.
Thanks... :)