Package org.jbpm.lob

Source Code of org.jbpm.lob.ClobStrategyClob

package org.jbpm.lob;

import java.sql.SQLException;

import org.hibernate.Hibernate;
import org.jbpm.PvmException;

public class ClobStrategyClob implements ClobStrategy {

  public void set(char[] chars, Clob clob) {
    if (chars!=null) {
      clob.setClob(Hibernate.createClob(new String(chars)));
    }
  }

  public char[] get(Clob clob) {
    java.sql.Clob sqlClob = clob.getClob();
    if (sqlClob!=null) {
      try {
        int length = (int) sqlClob.length();
        String text = sqlClob.getSubString(1, length);
        return text.toCharArray();
      } catch (SQLException e) {
        throw new PvmException("couldn't extract chars out of clob", e);
      }
    }
    return null;
  }
}
TOP

Related Classes of org.jbpm.lob.ClobStrategyClob

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.