-->
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: Trouble Oracle CLOBS and JPA
PostPosted: Tue Jul 14, 2009 12:30 am 
Newbie

Joined: Fri Oct 26, 2007 9:30 am
Posts: 11
I'm trying to configure my project to deal with CLOBS in an Oracle 10g database.
Configuration:
- Oracle 10.2g
- Spring 2.5.5
- Hibernate Entity Manager 3.4.0.GA
- Hibernate Annotations 3.4.0.GA
- Hibernate-core 3.3.2.GA
- driver 10.1.0.2.0

According to my book "Java Persistence with Hibernate" it should be possible to map CLOB types to string by annotating the field with the @Lob annotation.

However the query issued always fails with a type error
SQL Error: ORA-00932: inconsistent datatypes: expected - got CLOB
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:


here are snippets:

my persitent class:
Code:
@Table(name = "xedoc_admin.tbl_notes")
public class Note implements java.io.Serializable {

   @SuppressWarnings("unused")
   @Column(name="OBJ_VESION")
   private int version;
   
   private Integer id;
...
   private String note;
...

   @Lob
   @Column(name = "note", nullable = true)   
   public String getNote() {
      return this.note.toString();
   }

   public void setNote(String note) {
      this.note = note;
   }
...
}


my JPA entityManager:
Code:
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>                                 
        </property>
        <property name="jpaProperties">
            <util:properties location="classpath:com/adobe/xedoc/dao/jpa/hibernate.properties"/>
        </property>
    </bean>

hibernate.properties:
Code:
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.connection.isolation=4
hibernate.show_sql=false
hibernate.jdbc.batch_size = 0


I searched the web including this forum and came accross many posts discussing this issue but most were pretty old and complicated solutions. There were several different directions, so I'm pretty confused regarding the best choice for today.

The the simple and obvious things I tried include:
I have tried setting <connection-property name="SetBigStringTryClob">true</connection-property> on my JNDI datasource, I have also tried to explicitly set the mapping type: by annotating my getter with
@Type(type = "org.hibernate.type.TextType")

What is solution of choice today?

What is th eroot cause of the problem?

TIA

Jacques


Top
 Profile  
 
 Post subject: Re: Trouble Oracle CLOBS and JPA
PostPosted: Tue Jul 14, 2009 2:35 pm 
Newbie

Joined: Fri Oct 26, 2007 9:30 am
Posts: 11
How do I make hibernate honor the type of the entity (CLOB)?
The query should probably wrap the reference to the clob with a to_char(...) function.

But the query simply fails get any data at all. I suppose If I could make hibernate send a correct query handling the result would not be a problem.

Thanks for help.

Jacques


Top
 Profile  
 
 Post subject: Re: Trouble Oracle CLOBS and JPA
PostPosted: Wed Jul 15, 2009 1:45 am 
Newbie

Joined: Fri Oct 26, 2007 9:30 am
Posts: 11
Found the root cause: My select statement used the "DISTINCT" keyword in a query for an entity that had a Clob type.

DISTINCT requires a UNION which is not supported for Clobs in Oracle 10g.

I changed my queries so that I don't need to use DISTINCT any more.


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.