IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes Problem persisting id field with an autoincrement field Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Problem persisting id field with an autoincrement field" Watch "Problem persisting id field with an autoincrement field" New topic
Author

Problem persisting id field with an autoincrement field

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 745
Hi guys! I'm trying the CRUD functionality with netbeans 5.5. Thing used to be ok until I tried creating an identity columnn in SQLSever 2005. It says...



Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Cannot insert explicit value for identity column in table 'user_types' when IDENTITY_INSERT is set to OFF.Error Code: 544 Call:INSERT INTO user_types (user_type_id, description) VALUES (?, ?) bind => [null, Administrator] Query:InsertObjectQuery(com.worldpartner.wpinventory.UserTypes[userTypeId=null])
Exception Description: No transaction is currently active


It seems like SQLServer doesn't like taking the input NULL or anything in the autoincrement column. But ofcourse my userType bean would always persist that id field. What could be wrong? Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://game-rumble.com/ - http://everypesocounts.com/
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

How do you map that id? There are probably many different generation types that Toplink defines, and maybe you aren't using the correct one.

like in Hibernate there is "native", "auto-increment" and "identity"

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: Problem persisting id field with an autoincrement field
 
Threads others viewed
Problem with OJB
Hibernate @GeneratedValue problem
TOPLINK-41 for SQL Server 2005 and Identity Column
How to update table with autoincrement column in JSF application
Problems using GenerationType.IDENTITY for in-memory databases
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture