-->
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.  [ 3 posts ] 
Author Message
 Post subject: identity in MSSQL
PostPosted: Tue Feb 03, 2004 3:13 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
I used h2.1rc1 with MSSQL. I configed xml like this:
<id column="book_id" name="id" type="long" unsaved-value="0">
<generator class="identity"/>
</id>
I wanted the PK column book_id's value would be filled by database. But Hibernate throws Exception when I insert record into database.
could not insert: [h2test.test.Book]

java.sql.SQLException: [Microsoft][SQLServer JDBC Driver][SQLServer]Cannot insert the value NULL into column 'book_id', table 'test.dbo.Book'; column does not allow nulls. INSERT fails.

Why?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 4:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Probably you simply havent declared the book_id column as a identity column in your db?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 5:42 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
You are right.
Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.