What is the alternate for deprecated Hibernate.createClob(Reader reader, int length)

后端 未结 3 1072
轮回少年
轮回少年 2020-12-21 01:33

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)

相关标签:
3条回答
  • 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());
    
    0 讨论(0)
  • 2020-12-21 02:26

    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;
    /*      */   }
    
    0 讨论(0)
  • 2020-12-21 02:32

    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));
        }
    
    0 讨论(0)
提交回复
热议问题