Example usage for org.hibernate.type BinaryType INSTANCE

List of usage examples for org.hibernate.type BinaryType INSTANCE

Introduction

In this page you can find the example usage for org.hibernate.type BinaryType INSTANCE.

Prototype

BinaryType INSTANCE

To view the source code for org.hibernate.type BinaryType INSTANCE.

Click Source Link

Usage

From source file:debop4k.data.orm.hibernate.usertypes.compress.CompressedByteArrayUserType.java

License:Apache License

@Override
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
        throws HibernateException, SQLException {
    byte[] compressedBytes = BinaryType.INSTANCE.nullSafeGet(rs, names[0], session);
    return decompress(compressedBytes);
}

From source file:debop4k.data.orm.hibernate.usertypes.compress.CompressedByteArrayUserType.java

License:Apache License

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
        throws HibernateException, SQLException {
    if (value == null) {
        BinaryType.INSTANCE.nullSafeSet(st, null, index, session);
    } else {//ww  w.java 2 s. c  o  m
        byte[] compressedBytes = compress((byte[]) value);
        BinaryType.INSTANCE.nullSafeSet(st, compressedBytes, index, session);
    }
}

From source file:debop4k.data.orm.hibernate.usertypes.compress.CompressedObjectUserType.java

License:Apache License

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
        throws HibernateException, SQLException {
    if (value == null) {
        BinaryType.INSTANCE.nullSafeSet(st, null, index, session);
    } else {//  w w w.  j  av  a 2  s.  c  o m
        byte[] compressedBytes = compress(value);
        BinaryType.INSTANCE.nullSafeSet(st, compressedBytes, index, session);
    }
}

From source file:debop4k.data.orm.hibernate.usertypes.compress.CompressedStringUserType.java

License:Apache License

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
        throws HibernateException, SQLException {
    if (value == null) {
        BinaryType.INSTANCE.nullSafeSet(st, null, index, session);
    } else {/*from   www  .j a v a2  s.com*/
        byte[] compressedBytes = compress((String) value);
        BinaryType.INSTANCE.nullSafeSet(st, compressedBytes, index, session);
    }
}

From source file:debop4k.data.orm.hibernate.usertypes.compress.CompressedUserType.java

License:Apache License

@Override
public int[] sqlTypes() {
    return new int[] { BinaryType.INSTANCE.sqlType() };
}

From source file:kr.debop4j.data.hibernate.usertype.compress.AbstractCompressedBinaryUserType.java

License:Apache License

@Override
public Object nullSafeGet(final ResultSet resultSet, final String[] strings,
        final SessionImplementor sessionImplementor, final Object o) throws HibernateException, SQLException {
    try {/*  w ww . j  ava 2s. com*/
        byte[] value = BinaryType.INSTANCE.nullSafeGet(resultSet, strings[0], sessionImplementor);
        return decompress(value);
    } catch (Exception ex) {
        log.error("column=" + strings[0] + "  ?  ?? .", ex);
        throw new HibernateException("?  ?? .", ex);
    }
}

From source file:kr.debop4j.data.hibernate.usertype.compress.AbstractCompressedBinaryUserType.java

License:Apache License

@Override
public void nullSafeSet(final PreparedStatement preparedStatement, final Object o, final int i,
        final SessionImplementor sessionImplementor) throws HibernateException, SQLException {
    try {//w  ww. ja v  a 2s . c o m
        byte[] value = ArrayTool.isEmpty((byte[]) o) ? null : compress((byte[]) o);
        BinaryType.INSTANCE.nullSafeSet(preparedStatement, value, i, sessionImplementor);
    } catch (Exception ex) {
        log.error("Statement=[{}], index=[{}]?  ? ? .",
                preparedStatement, i);
        throw new HibernateException(" ? .", ex);
    }
}

From source file:kr.debop4j.data.hibernate.usertype.compress.AbstractCompressedBinaryUserType.java

License:Apache License

@Override
public boolean isMutable() {
    return BinaryType.INSTANCE.isMutable();
}

From source file:kr.debop4j.data.hibernate.usertype.compress.AbstractCompressedStringUserType.java

License:Apache License

@Override
public Object nullSafeGet(final ResultSet resultSet, final String[] strings,
        final SessionImplementor sessionImplementor, final Object o) throws HibernateException, SQLException {
    try {/*from ww  w . j  ava2  s .c o m*/
        byte[] value = BinaryType.INSTANCE.nullSafeGet(resultSet, strings[0], sessionImplementor);
        return decompress(value);
    } catch (Exception ex) {
        log.error("column=[" + strings[0] + "]  ?  ?? .",
                ex);
        throw new HibernateException("?  ?? .", ex);
    }
}

From source file:kr.debop4j.data.hibernate.usertype.compress.AbstractCompressedStringUserType.java

License:Apache License

@Override
public void nullSafeSet(final PreparedStatement preparedStatement, final Object o, final int i,
        final SessionImplementor sessionImplementor) throws HibernateException, SQLException {
    try {//from  w w  w . j  a va  2s.c  o  m
        byte[] value = compress((String) o);
        BinaryType.INSTANCE.nullSafeSet(preparedStatement, value, i, sessionImplementor);
    } catch (Exception ex) {
        log.error("Statement=[" + preparedStatement + "], index=[" + i
                + "]?  ? ? .", ex);
        throw new HibernateException("?  ?? .", ex);
    }
}