@Override public String[] getRegistrationKeys() { return new String[] { getName(), Timestamp.class.getName(), java.util.Date.class.getName() }; }
@Override public Date next(Date current, SharedSessionContractImplementor session) { return seed( session ); }
@Override public Date fromStringValue(String xml) throws HibernateException { return fromString( xml ); } }
public Object nullSafeGet(ResultSet resultSet, String string) throws SQLException { Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, string); if (timestamp == null) { return null; } return new DateTime(timestamp); }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, ((DateTime) value).toDate(), index); } }
/********************** Member Functions **************************/ @Override public int[] sqlTypes() { return new int[] { TimestampType.INSTANCE.sqlType(), }; }
@Override public Comparator<Date> getComparator() { return getJavaTypeDescriptor().getComparator(); }
SQLQuery hibernateQuery = getSession().createSQLQuery(sqlQuery); Set<String> columns = columnDataTypes.keySet(); for (String column : columns) { if (columnDataTypes.get(column).equals(SqlType.DATE.name())) { hibernateQuery.addScalar(column, new TimestampType()); } else { hibernateQuery.addScalar(column); } }
@Override public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor session, final Object owner) throws HibernateException, SQLException { final Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(rs, names[0], session, owner); if (timestamp == null) { return null; } return new DateTime(timestamp); }
@Override public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SessionImplementor session) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(st, null, index, session); } else { StandardBasicTypes.TIMESTAMP.nullSafeSet(st, ((DateTime) value).toDate(), index, session); } }
@Override public int[] sqlTypes() { return new int[]{StandardBasicTypes.TIMESTAMP.sqlType()}; }
public Comparator<Date> getComparator() { return getJavaTypeDescriptor().getComparator(); }
@Override public void visitSql(final SqlRestriction restriction) { if (restriction.getParameters() != null && restriction.getParameters().length > 0) { // Map our {@link Type} enum values to {@link org.hibernate.type.Type} equivalents org.hibernate.type.Type[] types = Arrays.stream(restriction.getTypes()).map(t -> { switch(t) { case FLOAT: return new FloatType(); case INTEGER: return new IntegerType(); case LONG: return new LongType(); case STRING: return new StringType(); case TIMESTAMP: return new TimestampType(); default: throw new UnsupportedOperationException("Unsupported type specified in SqlRestriction"); } }).collect(Collectors.toList()).toArray(new org.hibernate.type.Type[restriction.getTypes().length]); m_criterions.add(org.hibernate.criterion.Restrictions.sqlRestriction(restriction.getAttribute(), restriction.getParameters(), types)); } else { m_criterions.add(org.hibernate.criterion.Restrictions.sqlRestriction(restriction.getAttribute())); } }
@Override public Date seed(SharedSessionContractImplementor session) { if ( session == null ) { LOG.trace( "Incoming session was null; using current jvm time" ); return super.seed( null ); } else if ( !session.getJdbcServices().getJdbcEnvironment().getDialect().supportsCurrentTimestampSelection() ) { LOG.debug( "Falling back to vm-based timestamp, as dialect does not support current timestamp selection" ); return super.seed( session ); } else { return getCurrentTimestamp( session ); } }
final String revisionInfoTimestampSqlType = TimestampType.INSTANCE.getName(); final Element timestampProperty = MetadataTools.addProperty( mappingContext.getAuditEntityMapping(),
@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; } return new DateTime(timestamp); }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, ((DateTime) value).toDate(), index); } }
public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { statement.setNull(index, StandardBasicTypes.TIMESTAMP.sqlType()); statement.setNull(index + 1, StandardBasicTypes.TIMESTAMP.sqlType()); return; } Interval interval = (Interval) value; statement.setTimestamp(index, asTimeStamp(interval.getStart())); statement.setTimestamp(index + 1, asTimeStamp(interval.getEnd())); }
public Date fromStringValue(String xml) throws HibernateException { return fromString( xml ); } }
public Comparator<Date> getComparator() { return getJavaTypeDescriptor().getComparator(); }