-->
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.  [ 3 posts ] 
Author Message
 Post subject: Select generator results in JDBC ex converting ROWID to int
PostPosted: Sat Sep 23, 2006 3:09 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
Hibernate 3.0.5, Spring 1.2.8, JDK 1.4.2, Oracle 9i, WebLogic 8.14.

To summarize some issues I've been asking about in the last couple of days, I'm seeing an exception like the following when I try to write a row using a "select" generator where the table has a trigger and a sequence to create the primary key value. My "select" generator is just trying to read the column value that would have been created by the trigger.

From my HBM file:

<id name="oid">
<column name="OID"/>
<generator class="select">
<param name="key">OID</param>
</generator>
</id>


The root cause stack trace is the following:

Caused by: java.sql.SQLException: [BEA][Oracle JDBC Driver]Value can not be converted to requested type.
at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
at weblogic.jdbc.base.BaseData.getInteger(Unknown Source)
at weblogic.jdbc.base.BaseResultSet.getInt(Unknown Source)
at weblogic.jdbc.wrapper.ResultSet_weblogic_jdbc_base_BaseResultSet.getInt(Unknown Source)
at org.hibernate.id.IdentifierGeneratorFactory.get(IdentifierGeneratorFactory.java:65)
at org.hibernate.id.IdentifierGeneratorFactory.getGeneratedIdentity(IdentifierGeneratorFactory.java:36)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1761)

Note that the line numbers in IdentifierGeneratorFactory.java don't correspond exactly to what you would see in Hibernate 3.0.5 because I added some debug lines to the "get()" method, to print out information about the resultset. Line 65 listed above is the following line:

return new Integer( rs.getInt(1) );

The debug output that I got was:

resultset[weblogic.jdbc.wrapper.ResultSet_weblogic_jdbc_base_BaseResultSet@166]
Resultset:
table[] label[ROWID] name[ROWID] type[rowid] classname[java.lang.String]


I googled for ROWID in Hibernate and Oracle, and I found some information, but not enough to help me understand what is happening here.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 24, 2006 1:35 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
Just a small update.

I verified that the actual type of the ROWID column is String, and not Int, as Hibernate seems to think. In one case, it was a value like "AAAWM9AALAAAEJKAAC".

I searched through the Hibernate source for anything that might indicate what type it thought "ROWID" would be, and the only thing that came close was line 100 in "Oracle9Dialect.java", which is this:

registerFunction( "rowid", new NoArgSQLFunction("rowid", Hibernate.LONG, false) );

That refers to LONG, not INTEGER, so this is likely unrelated.

I'm out of ideas here.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 2:49 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
I decided to try upgrading to Hibernate 3.1.3 to see if it fixes this, or changes it, at least.

After I got past an apparently common problem with "Unsupported method: Connection.prepareStatement", which I resolved by setting to false the "hibernate.jdbc.use_get_generated_keys" property, the one thing that 3.1.3 helps me with is pointing out that I was mistakenly specifying a column name for the value of the "key" property, instead of a property name.

After thinking about this some more, however, and rereading the documentation and example on the "select" generator, it seems like this generator won't work for me. It appears this can only work if I have both a synthetic key (oid/OID) and a natural key, where I specify the property for the natural key for the select generator.

I think I have to conclude that my design to have a synthetic key where there isn't a single natural key will just not work. This table has a natural key, but it's a composite key. I guess I'm simply going to have to abandon the synthetic key and use the composite key directly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.