Example usage for org.hibernate.type.descriptor.java DataHelper extractString

List of usage examples for org.hibernate.type.descriptor.java DataHelper extractString

Introduction

In this page you can find the example usage for org.hibernate.type.descriptor.java DataHelper extractString.

Prototype

public static String extractString(final Clob value) 

Source Link

Document

Extract the contents of the given Clob as a string.

Usage

From source file:org.jasig.portal.dao.usertype.QNameTypeDescriptor.java

License:Apache License

@Override
public <X> QName wrap(X value, WrapperOptions options) {
    if (value == null) {
        return null;
    }/*from  www. ja  v a 2s  . com*/

    final String strValue;
    if (String.class.isInstance(value)) {
        strValue = (String) value;
    } else if (Reader.class.isInstance(value)) {
        strValue = DataHelper.extractString((Reader) value);
    } else if (Clob.class.isInstance(value) || DataHelper.isNClob(value.getClass())) {
        try {
            strValue = DataHelper.extractString(((Clob) value).getCharacterStream());
        } catch (SQLException e) {
            throw new HibernateException("Unable to access lob stream", e);
        }
    } else {
        throw unknownWrap(value.getClass());
    }

    return this.fromString(strValue);
}