BigIntegerType implements UserType { @Override public Object nullSafeGet(final ResultSet rs, final String[] names, final SharedSessionContractImplementor session, final Object owner) throws HibernateException, SQLException { byte[] idAsBytes = rs.getBytes(names[0]); if (idAsBytes == null) { return null; } return new BigInteger(idAsBytes); }  @Override int[] sqlTypes(); @Override Class returnedClass(); @Override boolean equals(final Object x,
                          final Object y); @Override int hashCode(final Object x); @Override Object nullSafeGet(final ResultSet rs,
                              final String[] names,
                              final SharedSessionContractImplementor session,
                              final Object owner); @Override void nullSafeSet(final PreparedStatement st,
                            final Object value,
                            final int index,
                            final SharedSessionContractImplementor session); @Override Object deepCopy(final Object value); @Override boolean isMutable(); @Override Serializable disassemble(final Object value); @Override Object assemble(final Serializable cached,
                           final Object owner); @Override Object replace(final Object original,
                          final Object target,
                          final Object owner);  }
@Test public void nullSafeGet() throws Exception { BigIntegerType type = new BigIntegerType(); String[] names = new String[]{"test"}; ResultSet rs = Mockito.mock(ResultSet.class); BigInteger one = IdUtil.next(); Mockito.doReturn(one.toByteArray()) .when(rs).getBytes(names[0]); BigInteger result = (BigInteger) type.nullSafeGet(rs, names, null, null); assertEquals(one, result); }
@Test public void nullSafeGetNull() throws Exception { BigIntegerType type = new BigIntegerType(); String[] names = new String[]{"test"}; ResultSet rs = Mockito.mock(ResultSet.class); Mockito.doReturn(null).when(rs).getString(names[0]); BigInteger result = (BigInteger) type.nullSafeGet(rs, names, null, null); assertNull(result); }