8
EAST
과 NORTH
필드를 좌표 객체에 매핑하기 위해 최대 절전 모드에서 CompositeUserType
을 생성합니다. 현재 내 좌표 객체는 변경 불가능하며 가능한 경우이를 유지하려고합니다.불변 객체를위한 Hibernate CompositeUserType
내가 쓴 내 nullSafeGet
, 생성자 된 ResultSet에서 좌표를 당기고 전화 :
@Override
public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException {
Integer easting = (Integer)Hibernate.INTEGER.nullSafeGet(rs, names[0]);
Integer northing = (Integer)Hibernate.INTEGER.nullSafeGet(rs, names[1]);
if(easting==null || northing==null)
return null;
return new Coordinate(easting, northing);
}
내가의 좌표를 설정하려는 것으로 보인다 setPropertyValue
, 수행 할 작업을 모르겠어요 시간. CompositeUserType
으로 불변 개체를 인스턴스화 할 수 있습니까, 아니면 불가능하게하려고합니까?
(또한 한 번에 Hibernate.INTEGER에 대해 어떻게 사용되지하지만, 한 가지 것을 해결하려고 노력 ...) 당신이 그것에서 UnsupportedOperationException
을 던질 수 있도록