Example usage for org.hibernate.type TextType INSTANCE

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

Introduction

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

Prototype

TextType INSTANCE

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

Click Source Link

Usage

From source file:com.alliander.osgp.shared.hibernate.InetAddressUserType.java

License:Open Source License

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

From source file:com.alliander.osgp.shared.hibernate.InetAddressUserType.java

License:Open Source License

@Override
public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor session,
        final Object owner) throws SQLException {
    try {// w w w.j av  a 2 s  .c o  m
        final String value = (String) TextType.INSTANCE.nullSafeGet(rs, names, session, owner);
        if (value == null) {
            return null;
        } else {
            return InetAddress.getByName(value);
        }
    } catch (final UnknownHostException e) {
        LOGGER.warn("Exception thrown during nullSafeGet.", e);
        return null;
    }
}

From source file:com.alliander.osgp.shared.hibernate.InetAddressUserType.java

License:Open Source License

@Override
public void nullSafeSet(final PreparedStatement st, final Object value, final int index,
        final SessionImplementor session) throws SQLException {
    if (value != null) {
        final InetAddress address = (InetAddress) value;
        TextType.INSTANCE.nullSafeSet(st, address.getHostAddress(), index, session);
    } else {//from   w  w w.j  a  v  a  2s .  c  o  m
        TextType.INSTANCE.nullSafeSet(st, null, index, session);
    }
}