I'm trying to insert a simple record into a table with an identity field.
It is working currently with Hibernate 3.0 and I'm trying move to 3.1.3 but it crashes.
Here are the frameworks and version I use
c3p0 : 0.9.0.4
AS400 Driver (JT400) : 5.4.0.1
Spring : 1.2.5
Hibernate : 3.0.final and 3.1.3
Switching just Hibernate jar file between 3.0 and 3.1.3 makes and breaks while all other libraries remain same.
SQL produced by both 3.0 and 3.1.3 looks same but 3.1.3 crashes while preparing a statement.
Here are the stacktraces from both successful insert with 3.0 and an error with 3.1.3.
Log from 3.0
------------
org.hibernate.event.def.AbstractSaveEventListener generated identifier: , using strategy: org.hibernate.id.IdentityGenerator
org.hibernate.event.def.AbstractSaveEventListener saving [com.zzz.proj.audit.model.AuditMessage#<null>]
org.hibernate.event.def.AbstractSaveEventListener executing insertions
org.hibernate.persister.entity.BasicEntityPersister Inserting entity: com.zzz.proj.audit.model.AuditMessage (native id)
org.hibernate.jdbc.AbstractBatcher about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
org.hibernate.jdbc.AbstractBatcher opening JDBC connection
org.hibernate.SQL insert into DATA.PFAUDMSG (MSMFNO, MSPECD, MSRLSQ, MSMSG, MSRNUM, MSID) values (?, ?, ?, ?, ?, default)
Hibernate: insert into DATA.PFAUDMSG (MSMFNO, MSPECD, MSRLSQ, MSMSG, MSRNUM, MSID) values (?, ?, ?, ?, ?, default)
org.hibernate.jdbc.AbstractBatcher preparing statement
org.hibernate.persister.entity.BasicEntityPersister Dehydrating entity: [com.zzz.proj.audit.model.AuditMessage#<null>]
org.hibernate.type.StringType binding 'XXXXXX' to parameter: 1
org.hibernate.type.StringType binding 'ZZZZZZ' to parameter: 2
org.hibernate.type.IntegerType binding '1' to parameter: 3
org.hibernate.type.StringType binding 'This is a test' to parameter: 4
org.hibernate.type.IntegerType binding '9999' to parameter: 5
org.hibernate.id.IdentifierGeneratorFactory Natively generated identity: 4523133
org.hibernate.jdbc.AbstractBatcher about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
org.hibernate.jdbc.AbstractBatcher closing statement
org.hibernate.event.def.AbstractFlushingEventListener flushing session
org.hibernate.event.def.AbstractFlushingEventListener processing flush-time cascades
org.hibernate.event.def.AbstractFlushingEventListener dirty checking collections
org.hibernate.event.def.AbstractFlushingEventListener Flushing entities and processing referenced collections
org.hibernate.event.def.AbstractFlushingEventListener Processing unreferenced collections
org.hibernate.event.def.AbstractFlushingEventListener Scheduling collection removes/(re)creates/updates
org.hibernate.event.def.AbstractFlushingEventListener Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
org.hibernate.event.def.AbstractFlushingEventListener Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
org.hibernate.pretty.Printer listing entities:
org.hibernate.pretty.Printer com.zzz.proj.audit.model.AuditMessage{message=This is a test, royaltyRecordKey=component[manufacturerNumber,activityPeriod,sequenceNumber]{sequenceNumber=1, activityPeriod=ZZZZZZ, manufacturerNumber=XXXXXX}, runNumber=9999, id=4523133}
org.hibernate.event.def.AbstractFlushingEventListener executing flush
org.hibernate.event.def.AbstractFlushingEventListener post flush
org.hibernate.impl.SessionImpl closing session
org.hibernate.jdbc.AbstractBatcher closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
org.hibernate.jdbc.JDBCContext after transaction completion
org.hibernate.impl.SessionImpl after transaction completion
Log from 3.1.3
--------------
2006-06-15 11:32:52,348 DEBUG main org.hibernate.event.def.AbstractSaveEventListener saving [com.zzz.proj.audit.model.AuditMessage#<null>]
2006-06-15 11:32:52,348 DEBUG main org.hibernate.event.def.AbstractSaveEventListener executing insertions
2006-06-15 11:32:52,379 DEBUG main org.hibernate.persister.entity.AbstractEntityPersister Inserting entity: com.zzz.proj.audit.model.AuditMessage (native id)
2006-06-15 11:32:52,379 DEBUG main org.hibernate.jdbc.AbstractBatcher about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-06-15 11:32:52,379 DEBUG main org.hibernate.jdbc.ConnectionManager opening JDBC connection
2006-06-15 11:32:52,379 DEBUG main org.hibernate.SQL insert into DATA.PFAUDMSG (MSMFNO, MSPECD, MSRLSQ, MSMSG, MSRNUM, MSID) values (?, ?, ?, ?, ?, default)
Hibernate: insert into DATA.PFAUDMSG (MSMFNO, MSPECD, MSRLSQ, MSMSG, MSRNUM, MSID) values (?, ?, ?, ?, ?, default)
2006-06-15 11:32:52,379 DEBUG main org.hibernate.jdbc.AbstractBatcher preparing statement
2006-06-15 11:32:52,737 DEBUG main org.hibernate.util.JDBCExceptionReporter could not insert: [com.zzz.proj.audit.model.AuditMessage] [insert into DATA.PFAUDMSG (MSMFNO, MSPECD, MSRLSQ, MSMSG, MSRNUM, MSID) values (?, ?, ?, ?, ?, default)]
java.sql.SQLException: The driver does not support this function.
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:389)
at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1954)
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:45)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:435)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1948)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2405)
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 org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:598)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:358)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:595)
at com.zzz.proj.audit.persist.AuditMessageService.save(AuditMessageService.java:84)
at com.zzz.proj.audit.persist.AuditMessageService$$FastClassByCGLIB$$8257ab1d.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:118)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.zzz.proj.audit.persist.AuditMessageService$$EnhancerByCGLIB$$264cc4c8.save(<generated>)
at com.zzz.proj.NewprojTest.testInsertAuditMsg(NewprojTest.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
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 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)
2006-06-15 11:32:52,737 WARN main org.hibernate.util.JDBCExceptionReporter SQL Error: -99999, SQLState: IM001
2006-06-15 11:32:52,737 ERROR main org.hibernate.util.JDBCExceptionReporter The driver does not support this function.
2006-06-15 11:32:52,768 DEBUG main org.hibernate.impl.SessionImpl closing session
2006-06-15 11:32:52,768 DEBUG main org.hibernate.jdbc.ConnectionManager performing cleanup
2006-06-15 11:32:52,768 DEBUG main org.hibernate.jdbc.ConnectionManager releasing JDBC connection [ (open PreparedStatements: 1, globally: 1) (open ResultSets: 0, globally: 0)]
2006-06-15 11:32:52,768 DEBUG main org.hibernate.jdbc.JDBCContext after transaction completion
2006-06-15 11:32:52,768 DEBUG main org.hibernate.jdbc.ConnectionManager aggressively releasing JDBC connection
2006-06-15 11:32:52,768 DEBUG main org.hibernate.impl.SessionImpl after transaction completion
Hibernate Mapping
-----------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="com.zzz.proj.audit.model.AuditMessage"
schema="DATA"
table="PFAUDMSG">
<id name="id" type="java.lang.Integer" unsaved-value="0">
<column name="MSID" sql-type="decimal(8,0)" not-null="true"/>
<generator class="identity" />
</id>
<component name="royaltyRecordKey" class="com.zzz.jacl.model.royalty.RoyaltyRecordKey">
<property name="manufacturerNumber" type="java.lang.String">
<column name="MSMFNO" sql-type="char(6)" not-null="true"/>
</property>
<property name="activityPeriod" type="java.lang.String">
<column name="MSPECD" sql-type="char(6)" not-null="true"/>
</property>
<property name="sequenceNumber" type="int">
<column name="MSRLSQ" sql-type="decimal(7,0)" not-null="true"/>
</property>
</component>
<property name="message" type="java.lang.String">
<column name="MSMSG" sql-type="char(255)" not-null="true"/>
</property>
<property name="runNumber" type="int">
<column name="MSRNUM" sql-type="decimal(5, 0)" not-null="true"/>
</property>
</class>
</hibernate-mapping>
DAO
---
public class AuditMessageService extends HibernateDaoSupport {
public void save(AuditMessage auditMessage) {
super.getHibernateTemplate().save(auditMessage);
}
}
|