Example usage for org.hibernate.type StandardBasicTypes TIMESTAMP

List of usage examples for org.hibernate.type StandardBasicTypes TIMESTAMP

Introduction

In this page you can find the example usage for org.hibernate.type StandardBasicTypes TIMESTAMP.

Prototype

TimestampType TIMESTAMP

To view the source code for org.hibernate.type StandardBasicTypes TIMESTAMP.

Click Source Link

Document

The standard Hibernate type for mapping java.util.Date ( java.sql.Timestamp ) to JDBC java.sql.Types#TIMESTAMP TIMESTAMP .

Usage

From source file:kr.debop4j.data.hibernate.usertype.TimeRangeUserType.java

License:Apache License

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
        throws HibernateException, SQLException {

    if (value == null) {
        StandardBasicTypes.TIMESTAMP.nullSafeSet(st, null, index, session);
        StandardBasicTypes.TIMESTAMP.nullSafeSet(st, null, index + 1, session);
    } else {//from  w  w w. j  av a  2  s  .  c  om
        DateTimeRange range = asDateTimeRange(value);
        StandardBasicTypes.TIMESTAMP.nullSafeSet(st, range.getStart(), index, session);
        StandardBasicTypes.TIMESTAMP.nullSafeSet(st, range.getEnd(), index + 1, session);
    }
}

From source file:nl.gmt.data.contrib.joda.PersistentDateTime.java

License:Apache License

public Object nullSafeGet(ResultSet resultSet, String string, SessionImplementor session, Object owner)
        throws SQLException {
    Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, string, session, owner);
    if (timestamp == null) {
        return null;
    }/* w w  w  .j a  v  a  2 s. co m*/

    return new DateTime(timestamp);
}

From source file:nl.gmt.data.contrib.joda.PersistentDateTime.java

License:Apache License

@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 {//from  w  w  w . jav  a  2s  .c om
        StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, ((DateTime) value).toDate(), index,
                session);
    }
}

From source file:nl.gmt.data.contrib.joda.PersistentLocalDateTime.java

License:Apache License

public Object nullSafeGet(ResultSet resultSet, String string, SessionImplementor session, Object owner)
        throws SQLException {
    Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, string, session, owner);
    if (timestamp == null) {
        return null;
    }/*from  w  ww.j av a  2s.com*/
    return new LocalDateTime(timestamp);
}

From source file:nl.gmt.data.contrib.joda.PersistentLocalDateTime.java

License:Apache License

@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 {//from  w  ww .  j  av  a2 s.  c  o m
        StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement,
                ((LocalDateTime) value).toDateTime().toDate(), index, session);
    }
}

From source file:org.jadira.usertype.spi.shared.AbstractTimestampColumnMapper.java

License:Apache License

@Override
public final TimestampType getHibernateType() {
    return StandardBasicTypes.TIMESTAMP;
}

From source file:org.jboss.as.quickstart.hibernate4.util.vertica.VerticaDialect6.java

License:Open Source License

protected void registerFunctions() {
    registerFunction("abs", new StandardSQLFunction("abs"));
    registerFunction("sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER));

    registerFunction("acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE));
    registerFunction("asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE));
    registerFunction("atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE));
    registerFunction("cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE));
    registerFunction("exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE));
    registerFunction("ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE));
    registerFunction("sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE));
    registerFunction("stddev", new StandardSQLFunction("stddev", StandardBasicTypes.DOUBLE));
    registerFunction("sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE));
    registerFunction("tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE));
    registerFunction("variance", new StandardSQLFunction("variance", StandardBasicTypes.DOUBLE));

    registerFunction("round", new StandardSQLFunction("round"));
    registerFunction("trunc", new StandardSQLFunction("trunc"));
    registerFunction("ceil", new StandardSQLFunction("ceil"));
    registerFunction("floor", new StandardSQLFunction("floor"));

    registerFunction("chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER));
    registerFunction("initcap", new StandardSQLFunction("initcap"));
    registerFunction("lower", new StandardSQLFunction("lower"));
    registerFunction("ltrim", new StandardSQLFunction("ltrim"));
    registerFunction("rtrim", new StandardSQLFunction("rtrim"));
    registerFunction("upper", new StandardSQLFunction("upper"));
    registerFunction("ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER));

    registerFunction("to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING));
    registerFunction("to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP));

    registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false));
    registerFunction("current_time", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIME, false));
    registerFunction("current_timestamp",
            new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false));

    registerFunction("last_day", new StandardSQLFunction("last_day", StandardBasicTypes.DATE));
    registerFunction("sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.DATE, false));
    registerFunction("user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false));

    // Multi-param string dialect functions...
    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("instr", new StandardSQLFunction("instr", StandardBasicTypes.INTEGER));
    registerFunction("instrb", new StandardSQLFunction("instrb", StandardBasicTypes.INTEGER));
    registerFunction("lpad", new StandardSQLFunction("lpad", StandardBasicTypes.STRING));
    registerFunction("replace", new StandardSQLFunction("replace", StandardBasicTypes.STRING));
    registerFunction("rpad", new StandardSQLFunction("rpad", StandardBasicTypes.STRING));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("substrb", new StandardSQLFunction("substrb", StandardBasicTypes.STRING));
    registerFunction("translate", new StandardSQLFunction("translate", StandardBasicTypes.STRING));

    registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("bit_length", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "vsize(?1)*8"));
    registerFunction("coalesce", new NvlFunction());

    // Multi-param numeric dialect functions...
    registerFunction("atan2", new StandardSQLFunction("atan2", StandardBasicTypes.FLOAT));
    registerFunction("log", new StandardSQLFunction("log", StandardBasicTypes.INTEGER));
    registerFunction("mod", new StandardSQLFunction("mod", StandardBasicTypes.INTEGER));
    registerFunction("nvl", new StandardSQLFunction("nvl"));
    registerFunction("nvl2", new StandardSQLFunction("nvl2"));
    registerFunction("power", new StandardSQLFunction("power", StandardBasicTypes.FLOAT));

    // Multi-param date dialect functions...
    registerFunction("add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE));
    registerFunction("months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT));
    registerFunction("next_day", new StandardSQLFunction("next_day", StandardBasicTypes.DATE));

}

From source file:org.joda.time.contrib.hibernate.PersistentDateTime.java

License:Apache License

public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
        throws HibernateException, SQLException {
    Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(rs, names[0], session, owner);
    if (timestamp == null) {
        return null;
    }/*from ww w .  j av  a2  s . c o m*/

    return new DateTime(timestamp);
}

From source file:org.joda.time.contrib.hibernate.PersistentDateTime.java

License:Apache License

public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session)
        throws HibernateException, SQLException {
    if (value == null) {
        StandardBasicTypes.TIMESTAMP.nullSafeSet(statement, null, index, session);
    } else {//from w w  w. ja va  2 s.  c  om
        StandardBasicTypes.TIMESTAMP.nullSafeSet(statement, ((DateTime) value).toDate(), index, session);
    }
}

From source file:org.joda.time.contrib.hibernate.PersistentDateTimeTZ.java

License:Apache License

public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
        throws HibernateException, SQLException {
    Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(rs, names[0], session, owner);
    Object timezone = StandardBasicTypes.STRING.nullSafeGet(rs, names[1], session, owner);
    if (timestamp == null || timezone == null) {
        return null;
    }/*from w  w  w.  ja  va  2 s .c om*/
    return new DateTime(timestamp, DateTimeZone.forID(timezone.toString()));
}