Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1rc3
Mapping documents:
<?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 package="com.rsr.test.om">
<class name="Bug" table="test_bug">
<!-- Common id property -->
<id name="id" type="long" column="bug_id"
unsaved-value="null">
<generator class="native" />
</id>
<property name="title" type="string" column="title"
not-null="true" />
<property name="description" type="text" column="description"
not-null="true" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
SessionFactory sf = new Configuration().configure()
.buildSessionFactory();
Session session = sf.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
Bug bug = new Bug("Hibernate Bug", "This code works fine with the DB2400 dialec in Hibernate 3.05, but it does NOT work with DB2400 dialec in Hibernate 3.1rc3");
session.saveOrUpdate(bug);
tx.commit();
} catch (HibernateException he) {
if (tx != null)
tx.rollback();
}
finally {
session.close();
}
Full stack trace of any exception that occurs:
org.hibernate.exception.GenericJDBCException: could not insert: [com.rsr.test.om.Bug]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1985)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2404)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
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.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:502)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:496)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:492)
at com.rsr.test.unit.HibernateTests.testAddBook(HibernateTests.java:22)
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 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: 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:1951)
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 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:1947)
... 27 more
Name and version of the database you are using:
AS/400 DB2 V5R3
The generated SQL (show_sql=true):
Hibernate: insert into test_bug (title, description, bug_id) values (?, ?, default)
Debug level Hibernate log excerpt:
Dec 2, 2005 1:58:47 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1 rc3
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.ibm.as400.access.AS400JDBCDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.current_session_context_class=thread, hibernate.dialect=org.hibernate.dialect.DB2400Dialect, hibernate.connection.username=webuser, hibernate.util.interceptor_class=com.rsr.common.dao.AuditInterceptor, hibernate.connection.url=jdbc:as400://as400_test;naming = system, hibernate.show_sql=true, hibernate.connection.password=****}
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: com/rsr/test/om/Bug.hbm.xml
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.rsr.test.om.Bug -> test_bug
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Dec 2, 2005 1:58:48 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Dec 2, 2005 1:58:48 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Dec 2, 2005 1:58:48 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Dec 2, 2005 1:58:48 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Dec 2, 2005 1:58:48 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.ibm.as400.access.AS400JDBCDriver at URL: jdbc:as400://as400_test;naming = system
Dec 2, 2005 1:58:48 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=webuser, password=****}
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: DB2 UDB for AS/400, version: 05.03.0000 V5R3m0
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: AS/400 Toolbox for Java JDBC Driver, version: 7.0
Dec 2, 2005 1:58:49 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2400Dialect
Dec 2, 2005 1:58:49 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Dec 2, 2005 1:58:49 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Dec 2, 2005 1:58:49 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Dec 2, 2005 1:58:49 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: POJO
Dec 2, 2005 1:58:49 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Dec 2, 2005 1:58:49 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Dec 2, 2005 1:58:49 PM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named HQL queries
Dec 2, 2005 1:58:49 PM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named SQL queries
Hibernate: insert into test_bug (title, description, bug_id) values (?, ?, default)
Dec 2, 2005 1:58:49 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -99999, SQLState: IM001
Dec 2, 2005 1:58:49 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: The driver does not support this function.