0 Replies Latest reply on Jan 17, 2011 10:21 AM by skymic

    JPA and creation of CLOBS in Oracle limited to 4000 bytes

    skymic

      Hi,

       

      I use a JBoss5.1.0_GA appserver and I have a JPA module which interacts with an Oracle database using oracle client 10.2.0.

       

      I use persistence classes which are entity beans. In some classes I have Strings which can contain large amounts of text data and I want them to be stored as CLOBS in oracle.

       

      I annotated the classes like this:

       

      @Entity

      @Table (name = "MY_TABLE")

      public  class MyClass implements Serializable {

       

      ...

       

       

       

      @Lob

      @Basic(fetch=FetchType.Lazy)

      @Column(name="MY_LOB", length=100000)

      private String myLob

       

      ...

       

      When I deploy my project on JBoss the table MY_TABLE is created and it contains a column called MY_LOB which is of type CLOB but the length is limited to 4000 bytes which is not enough for my application. The length of 100000 in the annotation is ignored.

      When I try to insert data into this CLOB it works as long as the data does not exceed 4000 bytes, otherwiese I get an Oracle Exception.

      My persistence.xml looks like this:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

      <persistence-unit name="MyNameJPA" transaction-type="JTA">

      <provider>org.hibernate.ejb.HibernatePersistence</provider>

      <jta-data-source>java:mydatasourceDS</jta-data-source>

      <exclude-unlisted-classes>true</exclude-unlisted-classes>

      <property name="hibernate.archive.autodetection" value="class"/>

      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/><property name="hibernate.show_sql" value="true"/><property name="hibernate.format_sql" value="true"/><property name="hibernate.hbm2ddl.auto" value="update"/><property name="hibernate.jdbc.batch_size" value="0"/><property name="hibernate.connection.SetBigStringTryClob" value="true"/></properties></persistence-unit>

       

      </persistence>

      Why are the CLOBS which are created by JPA/Hibernate limited to 4000 bytes?

      What can I do to tell JPA/Hibernate to set a limit of my choice?

      Any help?

       

      Thanks.