-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Auto-Increment Column with MySQL is not working..
PostPosted: Fri Oct 02, 2009 12:34 pm 
Newbie

Joined: Sat Sep 19, 2009 12:25 am
Posts: 7
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... :)


Top
 Profile  
 
 Post subject: Re: Auto-Increment Column with MySQL is not working..
PostPosted: Mon Oct 05, 2009 5:47 am 
Beginner
Beginner

Joined: Sat Aug 01, 2009 5:28 am
Posts: 42
hi,Can you post your code to make it more clear

_________________
Warm Regards,
Tarun Walia


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.