| .. | .. |
|---|
| 7 | 7 | import java.sql.Types; |
|---|
| 8 | 8 | |
|---|
| 9 | 9 | import org.hibernate.HibernateException; |
|---|
| 10 | | -import org.hibernate.engine.spi.SessionImplementor; |
|---|
| 10 | +import org.hibernate.engine.spi.SharedSessionContractImplementor; |
|---|
| 11 | 11 | import org.hibernate.usertype.UserType; |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | public abstract class PersistentEnumUserType<T extends CodedEnum> implements UserType { |
|---|
| .. | .. |
|---|
| 58 | 58 | } |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | @Override |
|---|
| 61 | | - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { |
|---|
| 61 | + public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) |
|---|
| 62 | + throws HibernateException, SQLException { |
|---|
| 62 | 63 | String code = rs.getString(names[0]); |
|---|
| 63 | 64 | for (CodedEnum en : returnedClass().getEnumConstants()) { |
|---|
| 64 | 65 | if (en.getCode().equals(code)) { |
|---|
| .. | .. |
|---|
| 69 | 70 | } |
|---|
| 70 | 71 | |
|---|
| 71 | 72 | @Override |
|---|
| 72 | | - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { |
|---|
| 73 | | - st.setString(index, value == null ? null : ((CodedEnum) value).getCode()); |
|---|
| 73 | + public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) |
|---|
| 74 | + throws HibernateException, SQLException { |
|---|
| 75 | + if (value == null) { |
|---|
| 76 | + st.setNull(index, java.sql.Types.VARCHAR); |
|---|
| 77 | + } else { |
|---|
| 78 | + st.setString(index, ((CodedEnum) value).getCode()); |
|---|
| 79 | + } |
|---|
| 74 | 80 | } |
|---|
| 75 | 81 | |
|---|
| 76 | 82 | } |
|---|