Code example for ResultSet

Methods: getInt, wasNull

0
	private static final long serialVersionUID = 1L;
 
	@Override 
	public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
			throws HibernateException, SQLException { 
		Integer value = rs.getInt(names[0]);
		if(rs.wasNull()){
			return null; 
		} 
		return TipoExercicio.fromCodigo(value);
	} 
 
	@Override 
	public void nullSafeSet(PreparedStatement st, Object value, int index)
			throws HibernateException, SQLException { 
		if (value==null){
			st.setNull(index, Types.TINYINT);
		}else{ 
			st.setInt(index, ((TipoExercicio) value).getCodigo());
		} 
	}