4 Replies Latest reply on Jul 10, 2008 2:22 PM by Gus Gu

    .. problems with clob's and oracle (ojdbc14_g)

    joern urban Newbie

      Hi all,

      .. i try to get a clob this way:

      ======================================

      @Entity @Table(name="TableName")
      @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
      public class ClassNamet {
       ***
       **
       *
       @Column(name="clob_col")
       private Clob contentAlt;
      ...
      ..
      .

      ======================================

      and get this error

      17:22:07,200 WARN [JDBCExceptionReporter] SQL Error: 932, SQLState: 42000
      17:22:07,200 ERROR [JDBCExceptionReporter] ORA-00932: inconsistent datatypes: expected - got CLOB


      .. i read lots of stuff about bugs in the jdbc drivers, but i need a solution. So if anybody knows something, please let me know!!!!!

      Thanks a lot,
      joern


        • 1. Re: .. problems with clob's and oracle (ojdbc14_g)
          Sandor Fiedler Newbie

          Hi joern,

          try to add the @Lob annotation to the member. We hava had the same problem and changed to the newest oracle driver (somewhat ojdbc5.jar), but I can't remember exactly what leads us to the success (will investigate more when I'm back to office next monday).
          Another guess is to add a columndefinition to the @Column annotation like ... columndefinition="BLOB" ... . If all that won't work try to store the large object as chunks of byte[255] arrays, at least this will work.

          Hope this gives you any hints to solve the problem.
          Regards
          \sandor\

          • 2. Re: .. problems with clob's and oracle (ojdbc14_g)
            joern urban Newbie

            hi sandor,

            .. thanks for your quick response.

            - i switched to the ojdbc5_g.jar oracle driver,
            - added this annotation,...

            @Entity @Table(name="TableName")
            @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
            public class ClassNamet {
             @Column(name="Name1")
             private String name1;
             @Column(name="Name2")
             private String name2;
             ***
             **
             *
            
             @Lob
             @Column(name="Col_Clob", columnDefinition="CLOB")
             private Clob col_clob;
            


            but still get the same error:

            12:55:27,831 WARN [JDBCExceptionReporter] SQL Error: 932, SQLState: 42000
            12:55:27,831 ERROR [JDBCExceptionReporter] ORA-00932: inconsistent datatypes: expected - got CLOB
            


            I#m also not 100% procent sure where it breaks. is it the oracle driver or is it the mapping? If u can tell me, how you solved it, that'll be perfect.

            thanks a lot,
            joern



            • 3. Re: .. problems with clob's and oracle (ojdbc14_g)
              Sandor Fiedler Newbie

              Hi Joern,

              the following works at least for our project

              @Lob
              @Basic(fetch=FetchType.EAGER)
              @Column(name = "MESSAGE", nullable = true)
              private byte[] message = null;
              


              Our environment is JBoss AS 4.2.2.GA, JDK 1.5.x, Oracle 10g. Give it a try and hopefully your response will message success.

              BTW the given byte[] must be de-/serialized by some code written on your own.

              \sandor\

              • 4. Re: .. problems with clob's and oracle (ojdbc14_g)
                Gus Gu Expert

                 

                "itsme" wrote:
                BTW the given byte[] must be de-/serialized by some code written on your own.

                Hi Sandor,

                May you share your de-/serialized codes? I googled "convert byte into string" and found many example codes, but I don't know which one is good for EJB3 byte. Thanks a lot.

                Gus