-->
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 - DB2 Identity Column Error
PostPosted: Wed Sep 20, 2006 2:33 pm 
Newbie

Joined: Wed Sep 20, 2006 2:16 pm
Posts: 2
Hi guys,

I am having a strange problem while inserting into db2 table. Hibernate is generating sql with "default" in it and DB2 does not like it.

What am I doing worng ?

Thanks.
Rahul.

-----------------------------------------------------------

Hibernate version: 3.1.3

Mapping:

<hibernate-mapping>
<class name="UvatSearch" table="UVATSRCH" dynamic-update="true" dynamic-insert="true" >
<id name="searchId" column="SEARCH_ID" type="long">
<generator class="identity" />
</id>
<property name="searchName" column="SEARCH_NAME" type="java.lang.String" length="50" not-null="true" />
<property name="searchDesc" column="SEARCH_DESC" type="java.lang.String" length="255" not-null="true" />
<property name="userName" column="USER_NAME" type="java.lang.String" length="48" not-null="true" />
<property name="pubRiInd" column="PUB_RI_IND" type="java.lang.String" length="1" not-null="true" />
</class>
</hibernate-mapping>

Table Defination
CREATE TABLE UVATSRCH"
(
SEARCH_ID INTEGER GENERATED ALWAYS AS IDENTITY not null,
SEARCH_NAME VARCHAR(50) not null,
SEARCH_DESC VARCHAR(255) not null,
USER_NAME VARCHAR(48) not null,
PUB_RI_IND CHAR(1) not null
);


// Open Session and Tx
UvatSearch search = new UvatSearch();
search.setSearchName("Test Search 1");
search.setSearchDesc("Description");
search.setPubRiInd("Y");
search.setUserName("qt85434");
session.save(search);
// Commit Tx and Close session


Hibernate: insert into TESTZD.UVATSRCH (SEARCH_NAME, SEARCH_DESC, SEARCH_ID, PUB_RI_IND, USER_NAME) values (?, ?, default, ?, ?)
6281 [main] WARN util.JDBCExceptionReporter - SQL Error: -302, SQLState: 22001
6281 [main] ERROR util.JDBCExceptionReporter - [IBM][CLI Driver][DB2] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use. SQLSTATE=22001

org.hibernate.exception.DataException: could not insert: [UvatSearch]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1986)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2398)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:530)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
at VASaveSearchTestCase.testCreateSearch(VASaveSearchTestCase.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use. SQLSTATE=22001

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.executeUpdate(Unknown Source)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1976)
... 30 more


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.