-->
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.  [ 7 posts ] 
Author Message
 Post subject: DB2400Dialect fails with Hibernate 3.1
PostPosted: Mon Jun 19, 2006 4:23 pm 
Newbie

Joined: Wed Jan 11, 2006 12:59 pm
Posts: 11
I think that the org.hibernate.dialect.DB2400Dialect does not work properly with Hibernate 3.1. When I try to save an object I get a "The driver does not support this function" error message. I have the latest jt400.jar file. If I use Hibernate 3.0 then it works fine. Is it possible this is a bug? What do I need to do to report this if it is a bug? Any help would be appreciated.


Hibernate version: 3.1


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">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping package="com.idfbins.domain.busent">
<class name="James" table="James" schema="CAPROTOTYP" catalog="FBMAS270">
<id name="id" type="long">
<column name="ID" />
<generator class="native" />
</id>
<property
name="notes"
column="NOTES"
type="string"
/>
</class>
</hibernate-mapping>


Code:
Code:
      James test1 = new James();
      test1.setNotes("hi");
      try {
         //temporary only. In future transaction should begin in constructor
         Transaction tx = SessionFactory.currentSession().beginTransaction();
         
         SessionFactory.currentSession().saveOrUpdate(test1);

         //temporary only. Later we will need to remove this commit and have the commit performed from the services layer.
         tx.commit();
      } catch (Exception ex) {
         //throw new InfrastructureException(ex);
         System.out.println("error" + ex.getMessage());
      }


Full stack trace of any exception that occurs:

14:14:05,251 DEBUG AbstractEntityPersister:1941 - Inserting entity: com.idfbins.domain.busent.James (native id)
14:14:05,251 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
14:14:05,267 DEBUG SQL:346 - insert into FBMAS270.CAPROTOTYP.James (NOTES, ID) values (?, default)
14:14:05,267 DEBUG AbstractBatcher:424 - preparing statement
14:14:05,282 DEBUG JDBCExceptionReporter:63 - could not insert: [com.idfbins.domain.busent.James] [insert into FBMAS270.CAPROTOTYP.James (NOTES, ID) 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:1974)
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:324)
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.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:494)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:490)
at com.idfbins.domain.busent.RunTests.main(RunTests.java:194)
14:14:05,282 WARN JDBCExceptionReporter:71 - SQL Error: -99999, SQLState: IM001
14:14:05,282 ERROR JDBCExceptionReporter:72 - The driver does not support this function.
errorcould not insert: [com.idfbins.domain.busent.James]


Name and version of the database you are using:
AS/400 DB2 V5R2
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 5:58 pm 
Newbie

Joined: Fri Jul 21, 2006 5:46 pm
Posts: 1
Location: Los Angeles California
This occurs because Hibernate calls the JT400.jar driver: com.ibm.as400.access.AS400JDBCDriver. In that driver the call to

public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException

is not implemented in the driver. The JavaDoc states, "This method is not supported. An SQLException is always thrown."

This method is referenced in the org.hibernate.util.GetGeneratedKeysHelper class:

static {
try {
PREPARE_STATEMENT_METHOD = Connection.class.getMethod( "prepareStatement", new Class[] { String.class, String[].class } );

Okay, now I have found where and why the exception is thrown, how do I fix it?

Thanx,
scott

_________________
Help Stamp Out Lazy Thinking


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 23, 2006 7:32 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:21 pm
Posts: 61
Location: Hannover
Hi,

some bad news for you. There is (still) no fix for this problem in Hibernate 3.1 or 3.2.
The issue is addressed in JIRA, but as far as I know now fix is available (but of course you can vote for it).

So you got the following options:
- Download the source, create you're own fix (compare 3.05 and 3.1 source) and maybe contribute a patch
- User Hibernate 3.05 (jt400 works fine here)
- Call IBM for fixing their problem with the jt400 driver


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 23, 2006 11:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
workaround: don't use getgenerated keys. (jdbc3)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 23, 2006 4:10 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:21 pm
Posts: 61
Location: Hannover
Does this mean, as long as I'm using assigned keys (generator="assigned") everything works fine?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 24, 2006 12:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
probably, but I was more thinking about configuring getGeneratedKeys.

look it up in the docs.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 12:25 pm 
Newbie

Joined: Wed Jul 27, 2005 11:20 am
Posts: 19
I had the same problem, see http://forum.hibernate.org/viewtopic.php?t=950850

One way to fix this is to use add the following line to your hibernate.properties files:

# Disable the use of JDBC3 PreparedStatement.getGeneratedKeys()
# This is necessary due to AS/400 JDBC driver having problems with
# the Hibernate identifier generators version 3.1.
hibernate.jdbc.use_get_generated_keys = false[/url]

_________________
Don Ngo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

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.