@Override public void nullSafeSet( PreparedStatement preparedStatement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index, session); } else { LocalDateTime ldt = ((LocalDateTime) value); Instant instant = ldt.atZone(ZoneId.systemDefault()).toInstant(); Date timestamp = Date.from(instant); StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, timestamp, index, session); } }
@Override public void nullSafeSet( PreparedStatement preparedStatement, Object value, int index, SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index, sessionImplementor); } else { StandardBasicTypes.TIMESTAMP.nullSafeSet( preparedStatement, ((LocalDate) value).toDate(), index, sessionImplementor); } }
@Override public void nullSafeSet( PreparedStatement st, Object value, int index, SharedSessionContractImplementor sharedSessionContractImplementor) throws HibernateException, SQLException { DateTime dt = (DateTime) value; if (dt == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(st, null, index, sharedSessionContractImplementor); StandardBasicTypes.STRING.nullSafeSet(st, null, index + 1, sharedSessionContractImplementor); } else { StandardBasicTypes.TIMESTAMP.nullSafeSet( st, dt.toDate(), index, sharedSessionContractImplementor); StandardBasicTypes.STRING.nullSafeSet( st, dt.getZone().getID(), index + 1, sharedSessionContractImplementor); } }
public Object nullSafeGet( ResultSet resultSet, String string, SessionImplementor sessionImplementor) throws SQLException { Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, string, sessionImplementor); if (timestamp == null) { return null; } return new LocalDate(timestamp); }
@Override public Object nullSafeGet( ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, names, session, owner); if (timestamp == null) { return null; } Date ts = (Date) timestamp; Instant instant = Instant.ofEpochMilli(ts.getTime()); return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); }
@Override public Object nullSafeGet( ResultSet rs, String[] names, SharedSessionContractImplementor sharedSessionContractImplementor, Object owner) throws HibernateException, SQLException { Timestamp timestamp = (Timestamp) StandardBasicTypes.TIMESTAMP.nullSafeGet( rs, names[0], sharedSessionContractImplementor, owner); String timezone = (String) StandardBasicTypes.STRING.nullSafeGet( rs, names[1], sharedSessionContractImplementor, owner); if (timestamp == null || timezone == null) return null; else return new DateTime(timestamp, DateTimeZone.forID(timezone)); }