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