Skip to content

Instantly share code, notes, and snippets.

@scottmarlow
Created July 12, 2018 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottmarlow/56a6d3c8675d6a426e86bd59fe65f166 to your computer and use it in GitHub Desktop.
Save scottmarlow/56a6d3c8675d6a426e86bd59fe65f166 to your computer and use it in GitHub Desktop.
public class StateType implements UserType {
// this represents what the transformer will generate
public Object nullSafeGet(ResultSet rs, String[] names, org.hibernate.SharedSessionContract session, Object owner) throws HibernateException, SQLException {
return nullSafeGet(rs,names, (SessionImplementor)session, owner);
}
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
int result = rs.getInt( names[0] );
if ( rs.wasNull() ) return null;
return State.values()[result];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment