-->
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.  [ 5 posts ] 
Author Message
 Post subject: Found: clob, expected: long - Oracle clob to Hibernate text
PostPosted: Tue Nov 13, 2012 11:29 am 
Pro
Pro

Joined: Mon Apr 16, 2007 8:10 am
Posts: 246
Hello,

I'm trying to map an Oracle column with type clob to an Hibernate text as:
Code:
      <property name="profile" type="text">
         <column name="profile" length="65535" />
      </property>


but it gives me an exception:
Quote:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Wrong column type in STEPHANE.ADMIN for column profile. Found: clob, expected: long


I installed the Oracle jdbc driver with the following command and setup:
Code:
mvn install:install-file -Dfile=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/jdbc/lib/ojdbc14.jar -Dpackaging=jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0

Code:
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc14</artifactId>
      <version>10.2.0</version>
    </dependency>


The jdbc driver was successfully installed and I can connect to the database.

I don't feel like touching the Hibernate mapping.

I could touch the Oracle table column definition, although I suspect a clob is what I need here.

Any clue ?


Top
 Profile  
 
 Post subject: Re: Found: clob, expected: long - Oracle clob to Hibernate text
PostPosted: Tue Nov 13, 2012 12:03 pm 
Pro
Pro

Joined: Mon Apr 16, 2007 8:10 am
Posts: 246
I also tried the following Hibernate setup:

<prop key="SetBigStringTryClob">true</prop>

and this one

<prop key="hibernate.connection.SetBigStringTryClob">true</prop>

but with each of them, the build still gave the same exception.


Top
 Profile  
 
 Post subject: Re: Found: clob, expected: long - Oracle clob to Hibernate text
PostPosted: Tue Nov 13, 2012 12:13 pm 
Pro
Pro

Joined: Mon Apr 16, 2007 8:10 am
Posts: 246
My version of Hibernate is 3.6.0.Final

I upgraded Hibernate to 3.5.4-Final and Spring to 3.1.3.RELEASE but the issue persists.

I'm using the hibernate.dialect=org.hibernate.dialect.Oracle10gDialect


Top
 Profile  
 
 Post subject: Re: Found: clob, expected: long - Oracle clob to Hibernate text
PostPosted: Wed Nov 14, 2012 8:23 am 
Pro
Pro

Joined: Mon Apr 16, 2007 8:10 am
Posts: 246
I also tried with another driver than the one shipped with my install of Oracle 10g XE server.

I found it at http://www.java2s.com/Code/Jar/o/Downloadojdbc14102040jar.htm

I installed it successfully with the command:

mvn install:install-file -Dfile=/home/stephane/programs/oracle/ojdbc14-10.2.0.4.0.jar -Dpackaging=jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0

Then I updated the dependency to reflect its name and version number as in:
Code:
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc14</artifactId>
      <version>10.2.0.4.0</version>
    </dependency>


But a build still gives the exact same error message.


Top
 Profile  
 
 Post subject: Re: Found: clob, expected: long - Oracle clob to Hibernate text
PostPosted: Wed Nov 14, 2012 9:53 am 
Pro
Pro

Joined: Mon Apr 16, 2007 8:10 am
Posts: 246
I solved the issue by declaring a custom driver in which the types were mapped as:
Code:
   public CustomOracle10gDialect() {
      super();
      registerColumnType(Types.LONGVARCHAR, "clob");
       registerColumnType(Types.LONGNVARCHAR, "clob");
   }


I ended up adding some more registered types due to other issues that showed up
Code:
       registerColumnType(Types.INTEGER, "number");
       registerColumnType(Types.BIT, "number");
       registerColumnType(Types.TIMESTAMP, "date");


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