Example usage for org.hibernate.type.descriptor WrapperOptions getJdbcTimeZone

List of usage examples for org.hibernate.type.descriptor WrapperOptions getJdbcTimeZone

Introduction

In this page you can find the example usage for org.hibernate.type.descriptor WrapperOptions getJdbcTimeZone.

Prototype

public TimeZone getJdbcTimeZone();

Source Link

Document

The JDBC TimeZone used when persisting Timestamp and DateTime properties into the database.

Usage

From source file:hibernate.type.descriptor.sql.ZonedDateTimeTypeDescriptor.java

License:LGPL

@Override
public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicExtractor<X>(javaTypeDescriptor, this) {
        @Override/*ww w.j a  v a 2s .c o  m*/
        protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
            return options.getJdbcTimeZone() != null
                    ? javaTypeDescriptor.wrap(
                            rs.getTimestamp(name, Calendar.getInstance(options.getJdbcTimeZone())), options)
                    : javaTypeDescriptor.wrap(rs.getTimestamp(name), options);
        }

        @Override
        protected X doExtract(CallableStatement statement, int index, WrapperOptions options)
                throws SQLException {
            return options.getJdbcTimeZone() != null ? javaTypeDescriptor.wrap(
                    statement.getTimestamp(index, Calendar.getInstance(options.getJdbcTimeZone())), options)
                    : javaTypeDescriptor.wrap(statement.getTimestamp(index), options);
        }

        @Override
        protected X doExtract(CallableStatement statement, String name, WrapperOptions options)
                throws SQLException {
            return options.getJdbcTimeZone() != null ? javaTypeDescriptor.wrap(
                    statement.getTimestamp(name, Calendar.getInstance(options.getJdbcTimeZone())), options)
                    : javaTypeDescriptor.wrap(statement.getTimestamp(name), options);
        }
    };
}