-->
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.  [ 37 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: DB2400 dialec not working in 3.1rc3
PostPosted: Fri Dec 02, 2005 4:00 pm 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
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.

_________________
Don Ngo


Top
 Profile  
 
 Post subject: More info on this problem
PostPosted: Fri Dec 02, 2005 4:22 pm 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
RUNTIME ENVIRONMENT
------------------------
JDBC Driver
JTOpen 4.9 http://jt400.sourceforge.net/

Database System
AS/400 v5R3

Test POJO
package com.rsr.test.om;

public class Bug {
private Long id;

private String title;

private String description;

/** Default constructor required by Hibernate */
public Bug() {
}

public Bug(String title, String description) {
this.title = title;
this.description = description;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String author) {
this.title = author;
}

public String getDescription() {
return description;
}

public void setDescription(String title) {
this.description = title;
}
}

Test Case
package com.rsr.test.unit;

import junit.framework.TestCase;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import com.rsr.test.om.Bug;

public class HibernateTests extends TestCase {
public void testAddBook() {
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();
he.printStackTrace();
}
finally {
session.close();
}
}
}

JDK
Version 1.5.0_06

hibernate.properties
# AS/400 DB2 Configuration
hibernate.dialect = org.hibernate.dialect.DB2400Dialect
hibernate.connection.driver_class = com.ibm.as400.access.AS400JDBCDriver
hibernate.connection.url = jdbc:as400://as400_test;naming = system
hibernate.connection.username = webuser
hibernate.connection.password = secret
hibernate.show_sql = true

hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- mapping files -->
<mapping resource="com/rsr/test/om/Bug.hbm.xml" />
</session-factory>
</hibernate-configuration>

SQL DDL
drop table test_bug;
create table test_bug (bug_id bigint generated by default as identity, title varchar(255) not null, description clob(255) not null, primary key (bug_id));

_________________
Don Ngo


Top
 Profile  
 
 Post subject: Here's something else I just found out
PostPosted: Fri Dec 02, 2005 5:23 pm 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
This problem appears to start with Hibernate 3.1rc3. Version 3.1rc2 works fine.

_________________
Don Ngo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 8:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
From org.hibernate.cfg.SettingsFactory:

Code:
boolean metaSupportsGetGeneratedKeys = false;

...

            if ( Environment.jvmSupportsGetGeneratedKeys() ) {
               try {
                  Boolean result = (Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", null)
                     .invoke(meta, null);
                  metaSupportsGetGeneratedKeys = result.booleanValue();
               }
               catch (AbstractMethodError ame) {
                  metaSupportsGetGeneratedKeys = false;
               }
               catch (Exception e) {
                  metaSupportsGetGeneratedKeys = false;
               }
            }

...

boolean useGetGeneratedKeys = PropertiesHelper.getBoolean(Environment.USE_GET_GENERATED_KEYS, properties, metaSupportsGetGeneratedKeys);




So the only way Hibernate will call getGeneratedKeys() is if either:

(1) you explicitly enable it OR
(2) the driver says it supports it

So it looks like your driver is lying to us.

Try disabling it explicitly using hibernate.jdbc.use_get_generated_keys=false


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2005 6:40 pm 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
Gavin, you're may be right, but I still have doubts since I have successfully applied Hibernate from version 3.05 through 3.1rc2 on several applications running on the AS/400 DB2. Furthermore, every application make heavy use of the auto-generated key feature. It's only when I attempted to migrate the same set of applications from using Hibernate 3.1rc2 to 3.1rc3 that this problem started to occur. In fact, the only change I made in the migration process is swapping out the jar files from Hibernate 3.1rc2 to 3.1rc3.

In trying to determine whether I have done something peculiar in the code that may have caused this problem to only occur in 3.1rc3 or this is in fact a bug that was introduced in 3.1rc3, I created the simple example that I posted earlier in this topic. With this simple example also producing the same error, I believe it is indeed a bug was introduced in 3.1rc3 release, and I'm hoping that you and your team can use this example to reproduce the error.

Regards,

Don Ngo

_________________
Don Ngo


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2005 6:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Um.

I have already explained the problem and fix to you.

Hibernate (for whatever reason: misconfiguration, or JDBC driver bug) is calling getGeneratedKeys(), which is not implemented by this driver.

Disable use of getGeneratedKeys() and the error will go away.

I'm not sure what is difficult to understand here?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2005 6:49 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I did make a change for rc3 relating to how PreparedStatements are built to utilize getGeneratedKeys.

We switched from http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html#prepareStatement(java.lang.String,%20int) to [url]http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html#prepareStatement(java.lang.String, java.lang.String[])[/url]

So it sounds more like an issue of the JDBC driver not fully supporting getGeneratedKeys even though it reports to do so.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2005 6:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Note that you do not have to use getGeneratedKeys() to use identity/autoincrement columns.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 11:53 am 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
Gavin,

I've tried running a test after updating the hibernate.properties file to disable the use of getGeneratedKeys() as you've suggested. I got a different error this time, but essentially, the net result is still the same: it's not working on 3.1rc3. I've even tried using the official, supported version of JDBC driver from IBM, and again the result is the same. This result is convincing me even more that there is indeed a bug that was introduced in 3.1rc3.

Note: I've also tried the test on MySQL without having to disable the getGeneratedKeys(), and it works fine on all version of Hibernate. This seems to implicate that this problem is specific to DB2400 dialec in Hibernate 3.1rc3 only.

For your reference, below is my updated hibernate.properties file and the log from the test run I made:

hibernate.properties
# Disable use of getGeneratedKeys()
hibernate.jdbc.use_get_generated_keys=false

# Display SQL statements for debugging
hibernate.show_sql = true

# AS/400 DB2 Configuration
hibernate.dialect = org.hibernate.dialect.DB2400Dialect
hibernate.connection.driver_class = com.ibm.as400.access.AS400JDBCDriver
hibernate.connection.url = jdbc:as400://as400_test;naming = system
hibernate.connection.username = webuser
hibernate.connection.password = dotgrid793

Test log
Dec 7, 2005 9:38:08 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1 rc3
Dec 7, 2005 9:38:08 AM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=webuser, hibernate.jdbc.use_get_generated_keys=false, hibernate.connection.password=****, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.DB2400Dialect, hibernate.connection.url=jdbc:as400://as400_test;naming = system, hibernate.show_sql=true, hibernate.connection.driver_class=com.ibm.as400.access.AS400JDBCDriver}
Dec 7, 2005 9:38:08 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Dec 7, 2005 9:38:08 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Dec 7, 2005 9:38:08 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Dec 7, 2005 9:38:08 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Dec 7, 2005 9:38:09 AM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: com/rsr/test/om/Bug.hbm.xml
Dec 7, 2005 9:38:09 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.rsr.test.om.Bug -> test_bug
Dec 7, 2005 9:38:09 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Dec 7, 2005 9:38:09 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Dec 7, 2005 9:38:09 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Dec 7, 2005 9:38:09 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Dec 7, 2005 9:38:09 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Dec 7, 2005 9:38:09 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Dec 7, 2005 9:38:09 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Dec 7, 2005 9:38:09 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Dec 7, 2005 9:38:09 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.ibm.as400.access.AS400JDBCDriver at URL: jdbc:as400://as400_test;naming = system
Dec 7, 2005 9:38:09 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=webuser, password=****}
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: DB2 UDB for AS/400, version: 05.03.0000 V5R3m0
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: AS/400 Toolbox for Java JDBC Driver, version: 7.0
Dec 7, 2005 9:38:10 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2400Dialect
Dec 7, 2005 9:38:10 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Dec 7, 2005 9:38:10 AM 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 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Dec 7, 2005 9:38:10 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Dec 7, 2005 9:38:10 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: POJO
Dec 7, 2005 9:38:11 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Dec 7, 2005 9:38:11 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Dec 7, 2005 9:38:11 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named HQL queries
Dec 7, 2005 9:38:11 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named SQL queries
Hibernate: insert into test_bug (title, description, bug_id) values (?, ?, default)
Hibernate: select identity_val_local() from sysibm.sysdummy1
Dec 7, 2005 9:38:11 AM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -5016, SQLState: 42833
Dec 7, 2005 9:38:11 AM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: [SQL5016] Qualified object name SYSDUMMY1 not valid.
org.hibernate.exception.SQLGrammarException: could not insert: [com.rsr.test.om.Bug]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.AbstractPostInsertGenerator.getGenerated(AbstractPostInsertGenerator.java:56)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1993)
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: [SQL5016] Qualified object name SYSDUMMY1 not valid.
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:650)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:621)
at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1481)
at com.ibm.as400.access.AS400JDBCPreparedStatement.<init>(AS400JDBCPreparedStatement.java:185)
at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1880)
at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1703)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:442)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
at org.hibernate.id.AbstractPostInsertGenerator.getGenerated(AbstractPostInsertGenerator.java:39)
... 28 more
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at com.rsr.logging.EmailHandler.sendMessage(EmailHandler.java:381)
at com.rsr.logging.EmailHandler.runWork(EmailHandler.java:300)
at com.rsr.logging.EmailHandler.access$0(EmailHandler.java:286)
at com.rsr.logging.EmailHandler$MessageThread.run(EmailHandler.java:419)

_________________
Don Ngo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 11:59 am 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
FYI: I've checked the JDBC driver source code, and it does have the getGeneratedKeys() method implemented. Below is an excerpt from the source code:

public class AS400JDBCStatement implements Statement
{
...

// JDBC 3.0
public ResultSet getGeneratedKeys ()
throws SQLException
{
cachedResultSet_ = null;
try {
JDResultSetProxy newResultSet = new JDResultSetProxy (jdConnection_, this);
cachedResultSet_ = (JDResultSetProxy) connection_.callFactoryMethod (
pxId_,
"getGeneratedKeys",
newResultSet);
return cachedResultSet_;
}
catch (InvocationTargetException e) {
throw JDConnectionProxy.rethrow1 (e);
}
}

...
}

_________________
Don Ngo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 12:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Right, now look at the source of Connection.prepareStatement(java.lang.String, java.lang.String[]), which is part of the JDBC getGeneratedKeys() functionality.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
And google (and the user who submitted the patch) insists that sysibm.sysdummy1 exists in DB2/AS400.

So I'm not sure why you get a warning from your JDBC driver.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 12:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Probably you just need to have permissions. Try

Code:
db2 GRANT select on sysibm.sysdummy1 to public


(Ask your DBA why you can't see SYSDUMMY1.)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 5:02 pm 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
Gavin/Steve:

I now know exactly why my previous test run didn't work even with the getGeneratedKeys() disabled. The problem lies in the way I've the JDBC driver settings in the hibernate.properties, specifically having the following line:

hibernate.connection.url = jdbc:as400://as400_test;naming = system

Having naming = system specifies the use of "System Naming" syntax in SQL statement, which means that instead of using the standard dot (.) notation to separate between the schema and table name, the forward slash (/) must used instead (There's a reason for me to use the "System Naming", which I will explain later). This also means that the following line, which was generated by Hibernate:

Code:
select identity_val_local() from sysibm.sysdummy1


will does not work using the "System Naming" syntax, since the dot was used instead of of the forward slash.

To fix this problem, I must use the "SQL Naming" syntax by removing naming = system from hibernate.connection.url configuration string within the hibernate.properties file. However, doing so also pose a new problem for me: I have a need to use the "System Naming" syntax, which is the only way the AS/400 will allow the "unqualified" table names with the SQL statements to be resolved by a list of schemas (a.k.a. "libraries" in AS/400 terminology) defined in the profile of the user (in my case [b]webuser[b/]) being used for accessing the AS/400 database. For example, I have configured the webuser account to having the following list of libraries in the profile:

WEBUSER
COR
RSRLIB

therefore, a SQL statement such as

Code:
SELECT * FROM CM_EMPLOYEES


would result in reading from the CM_EMPLOYEE table in WEBUSER, COR, and RSRLIB in that order, whichever is found first.

You may be wondering why do I need to have access to more than library, and the reason is that I have to work with a number of legacy tables that are scattered across multiple libraries due to various technical and business reasons. Moreover, some of the libraries are used as a staging (i.e. testing) area that have same set of tables with identical names as the other libraries, and the main reason for having so is to isolate the test database from the pre-production database, which reserved for final testing prior to roll out production. I have a user account setup for testing with pre-production database with specific library list setup for that purpose and a separate user account setup for testing the test database with specific library list for that purpose also, and so to switch between the two set of library list, I just need to change the user account in the hibernate.properties file. This also means that hard coding the library (or schema in Hibernate terminology) names in the hibernate mapping files would be impractical.

Having all that said, I have the following question to ask you:

Up to Hibernate version 3.1rc2, I did not have to disable the getGeneratedKeys() feature and I was able to use the "System Naming" syntax, why does 3.1rc3 now require this feature to be disabled, which also means that I can no longer use the "System Naming" syntax, which then pose another problem for me as I described earlier?

Whatever change that you made on 3.1rc3 must have caused this new requirement, and I just want to make another statement: I don't think I'm alone in having the need to use the "System Naming" syntax; you may additional reports from other people in the user community when they have a chance to try out the 3.1rc3 release.

BTW: I sincerely thank you all for providing such a superb O/R mapping product.[/code]

_________________
Don Ngo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 5:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is trivial to subclass DB2400Dialect and use whatever syntax you like. Just ask your DBA what works. Dialect is a published extension point in Hibernate.


The reason for the change is that Hibernate 3.1 now supports retrieving potentially multiple generated column values. This is a new feature of Hibernate (generated="true").


You should pressure IBM to support all overladed forms of prepareStatement() in their JDBC driver.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 37 posts ]  Go to page 1, 2, 3  Next

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.