-->
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: Unable to insert row into a DB2 table with identity column
PostPosted: Tue Jul 19, 2005 5:06 pm 
Newbie

Joined: Mon Jul 18, 2005 4:32 pm
Posts: 1
Somebody please help me. I am trying to insert a row to a Db2 table which has an identity column and having problems. I have the details below. The ID type in my java code is "int" and the identity column data type in DB2 table is also of type integer.

b]Hibernate version:[/b] 2.1

Mapping documents:
<id name="msgID" type="int" column="MSG_I" unsaved-value="0">
<generator class="identity" />
</id>

Code between sessionFactory.openSession() and session.close():
tx = sess.beginTransaction();
sess.save(noticeBean);
tx.commit();
sess.flush();

Full stack trace of any exception that occurs:
net.sf.hibernate.exception.SQLGrammarException: could not insert: [com.app.NoticeBean]
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:58)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:540)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:426)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:28)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:943)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:868)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:786)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
at com.app.insertMessageToDB(NoticePortletUtils.java:79)
at com.app.NoticePortletUtils.main(NoticePortletUtils.java:184)
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0142N The SQL statement is not supported. SQLSTATE=42612
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeQuery(Unknown Source)
at com.p6spy.engine.logging.P6LogPreparedStatement.executeQuery(P6LogPreparedStatement.java:172)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:530)
... 9 more
net.sf.hibernate.exception.SQLGrammarException: could not insert: [com.app.NoticeBean]
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:58)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:540)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:426)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:28)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:943)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:868)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:786)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
at com.app.NoticePortletUtils.insertMessageToDB(NoticePortletUtils.java:79)
at com.app.NoticePortletUtils.main(NoticePortletUtils.java:184)
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0142N The SQL statement is not supported. SQLSTATE=42612
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeQuery(Unknown Source)
at com.p6spy.engine.logging.P6LogPreparedStatement.executeQuery(P6LogPreparedStatement.java:172)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:530)
... 9 more
Name and version of the database you are using:
DB2
The generated SQL (show_sql=true):
insert into YYYDTBL.DBTP372_MSGS (MSG_DESC_STRNG, MSG_NEW_STRNG, MSG_PRTY_STRNG, MSG_TYP_STRNG, ACTV_ON_DTE_STRNG, EXPR_ON_DTE_STRNG, DSPLY_COLOR_STRNG, MSG_ORD_NO, LST_CHNG_UID, MSG_I) values (?, ?, ?, ?, ?, ?, ?, ?, ?, default)


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.