org.hibernate.type.BlobType Java Examples

The following examples show how to use org.hibernate.type.BlobType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZipJsonType.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Override
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
    if (value != null) {
        String json;
        synchronized (value) {
            json = JsonUtility.object2String(value);
        }
        byte[] bytes = json.getBytes(StringUtility.CHARSET);
        byte[] zip = PressUtility.zip(bytes, 5);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(zip);
        preparedStatement.setBinaryStream(index, inputStream);
    } else {
        preparedStatement.setNull(index, BlobType.INSTANCE.sqlType());
    }
}
 
Example #2
Source File: ModelBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static boolean isLob(Integer sqlType, String sqlTypeName) {
	if ( sqlType != null ) {
		return ClobType.INSTANCE.getSqlTypeDescriptor().getSqlType() == sqlType ||
				BlobType.INSTANCE.getSqlTypeDescriptor().getSqlType() == sqlType ||
				NClobType.INSTANCE.getSqlTypeDescriptor().getSqlType() == sqlType;
	}
	else if ( sqlTypeName != null ) {
		return ClobType.INSTANCE.getName().equalsIgnoreCase( sqlTypeName ) ||
				BlobType.INSTANCE.getName().equalsIgnoreCase( sqlTypeName ) ||
				NClobType.INSTANCE.getName().equalsIgnoreCase( sqlTypeName );
	}
	return false;
}
 
Example #3
Source File: ZipJsonType.java    From jstarcraft-core with Apache License 2.0 4 votes vote down vote up
@Override
public int[] sqlTypes() {
    return new int[] { BlobType.INSTANCE.sqlType() };
}
 
Example #4
Source File: BeanTransformerAdapter.java    From spring-data-jpa-extra with Apache License 2.0 4 votes vote down vote up
@Override
public String convert(Blob source) {
    return BlobType.INSTANCE.toString(source);
}