This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue in hibernate after modifying generator class from increment to identity  RSS feed

 
Sandy Java Geek
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a simple user.hmb.xml file to create a database table.
I just modified the generator class from increment to identity and now it throws SQL exception : java.sql.SQLException: Field 'ID' doesn't have a default value
Below is the User.hbm.xml file and the POJO User.java

<?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.model.User" table="user_master">
<id name="id" type="java.lang.Integer" column="ID">
<generator class="identity"></generator>
</id>

-----------------------------------------------------------------------------------------------------
User.java

 
Randy Maddocks
Ranch Hand
Posts: 134
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandy,

Welcome to JavaRanch!  

The issue could have something to do with your database schema. Perhaps this will help: Generation type identity gives error

Cheers!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!