class PGEnumUserType implements EnhancedUserType, ParameterizedType {

	@Override
	public Object nullSafeGet(final ResultSet rs, final String[] names,
			final SessionImplementor session, final Object owner)
			throws HibernateException, SQLException {
		Object object = rs.getObject(names[0]);
		if (rs.wasNull()) {
			return null;
		}

		// Notice how Object is mapped to PGobject. This makes this implementation Postgres specific
		if (object instanceof PGobject) {
			PGobject pg = (PGobject) object;
			return Enum.valueOf(enumClass, pg.getValue());
		}
		return null;
	}

}