4
votes

Seems like Hibernate.createClob(Reader reader, int length) is deprecated in version 3.6.x And it suggests to use Use LobHelper.createClob(Reader, long) instead.

But LobHelper is an interface not a class.

Is there any alternate for static method Hibernate.createClob(Reader reader, int length)?

3

3 Answers

5
votes

I was using the createBlob(bytes[]) from that class. I created a new class and the following method

    public static Blob createBlob(byte[] bytes) {
       return NonContextualLobCreator.INSTANCE.wrap(NonContextualLobCreator.INSTANCE.createBlob(bytes));
    }
4
votes

It is the way of simplifying the usage by hiding the implementations. If you want to use the Clob data you need to use the below code. I have tested it in version hibernate 3.6.

session.getLobHelper().createClob("the_string");

Now coming your second point about the working of it, if you read the source code of org.hibernate.impl.SessionImpl class you will know how internally hibernate handles this.

public LobHelper getLobHelper()
/*      */   {
/* 2245 */     if (this.lobHelper == null) {
/* 2246 */       this.lobHelper = new LobHelperImpl(this, null);
/*      */     }
/* 2248 */     return this.lobHelper;
/*      */   }
1
votes

I have found another good alternate for this, using java javax.sql.rowset.serial.SerialClob

For example

Clob clob = new SerialClob("Some very long String.......".toCharArray());