xiejun
2024-09-04 ac3f3629a261770f573f27e5e23f7ec19d096c2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.jbpm.pvm.internal.lob;
 
import java.sql.SQLException;
 
import org.hibernate.Hibernate;
import org.jbpm.api.JbpmException;
 
public class ClobStrategyClob implements ClobStrategy {
 
  public void set(char[] chars, Lob lob) {
    if (chars!=null) {
      lob.clob = Hibernate.createClob(new String(chars));
    }
  }
 
  public char[] get(Lob lob) {
    java.sql.Clob sqlClob = lob.clob;
    if (sqlClob!=null) {
      try {
        int length = (int) sqlClob.length();
        String text = sqlClob.getSubString(1, length);
        return text.toCharArray();
      } catch (SQLException e) {
        throw new JbpmException("couldn't extract chars out of clob", e);
      }
    } 
    return null;
  }
}