-->
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.  [ 1 post ] 
Author Message
 Post subject: JPA Hibernate GenerationType Identity not working
PostPosted: Mon Nov 05, 2007 6:55 pm 
Newbie

Joined: Mon Nov 05, 2007 6:38 pm
Posts: 1
PLEASE HELP. It seems that GenerationType.Identity is not working the SQL that gets generated for JPA Hibernate is added the @Id to the INSERT statement.


Hibernate version:
Hibernate 3.2.4.ga
Hibernate EntityManager 3.3.1.GA


Mapping documents: on JAVA
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "OID", insertable = false, updatable=false)


Full stack trace of any exception that occurs:
WARN org.hibernate.util.JDBCExceptionReporter (JDBCExceptionReporter.java:77)[] SQL Error: -1, SQLState: 42Z23
ERROR org.hibernate.util.JDBCExceptionReporter (JDBCExceptionReporter.java:78)[] Attempt to modify an identity column 'OID'.
Caused by: org.hibernate.exception.SQLGrammarException: could not insert: [com.expd.app.erms.domain.legacy.Carrier]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:131)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:213)
... 38 more
Caused by: java.sql.SQLException: Attempt to modify an identity column 'OID'.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:94)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:30)
... 53 more
Caused by: org.apache.derby.client.am.SqlException: Attempt to modify an identity column 'OID'.
at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
... 57 more



Name and version of the database you are using:
INFO org.hibernate.cfg.SettingsFactory (SettingsFactory.java:89)[] RDBMS: Apache Derby, version: 10.2.2.0 - (485682)
INFO org.hibernate.cfg.SettingsFactory (SettingsFactory.java:90)[] JDBC driver: Apache Derby Network Client JDBC Driver, version: 10.2.2.0 - (485682)
INFO org.hibernate.dialect.Dialect (Dialect.java:152)[] Using dialect: org.hibernate.dialect.DerbyDialect


The generated SQL (show_sql=true):
Hibernate:
insert
into
CERTS.CARRIER
(CREATE_STAMP, DEL_STAMP, MOD_STAMP, ADDRESS1, ADDRESS2, ADDRESS3, ADDRESS4, ADDRESS5, OID_BRANCH, CITY, COMPANY_NAME, CONTACT, COUNTRY, EMAIL, FAX, IS_ACTIVE, PHONE, STATE, ZIP, OID)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


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

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.