-->
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: Field 'id' doesn't have a default value
PostPosted: Thu Mar 27, 2008 2:38 pm 
Newbie

Joined: Fri Mar 21, 2008 10:44 pm
Posts: 4
Using annotations, here is the snapshot Java:

@Id
@GenericGenerator(name="test", strategy = "seqhilo")
@GeneratedValue(generator="test")
private Long id;

When I run the program, I got:

SEVERE: Servlet.service() for servlet default threw exception
java.sql.SQLException: Field 'id' doesn't have a default value
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3249)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1268)

I am using hibernate.hbm2ddl.auto in applicationContext.xml and I hope hibernate can take care of adding "auto-increment" attribute into the database table if needed. How should I configure xml and/or Java?

Thanks!


Top
 Profile  
 
 Post subject: Re: Field 'id' doesn't have a default value
PostPosted: Fri Mar 28, 2008 2:50 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
sloth_ll wrote:
@Id
@GenericGenerator(name="test", strategy = "seqhilo")
@GeneratedValue(generator="test")
private Long id;



I don't think auto increment would be right thing for you anyways. This is a mapping for a sequence identity. You might get a better result if you use an identity generator.




Farzad-


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.