List of usage examples for org.hibernate.type.descriptor.java JavaTypeDescriptor unwrap
<X> X unwrap(T value, Class<X> type, WrapperOptions options);
From source file:DstSafeDateTypeDescriptor.java
License:Apache License
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, (SqlTypeDescriptor) this) { @Override/*from w w w. j a va 2 s . c o m*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { if (cal == null) { st.setDate(index, javaTypeDescriptor.unwrap(value, Date.class, options)); } else { st.setDate(index, javaTypeDescriptor.unwrap(value, Date.class, options), cal); } } }; }
From source file:hibernate.type.descriptor.sql.ZonedDateTimeTypeDescriptor.java
License:LGPL
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override/*from ww w .j a v a 2 s . co m*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { final Timestamp timestamp = javaTypeDescriptor.unwrap(value, Timestamp.class, options); st.setObject(index, ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.of("+1"))); // if (st instanceof DruidPooledPreparedStatement) { // PreparedStatement raw = ((DruidPooledPreparedStatement)st).getRawPreparedStatement(); // raw.setObject(index, ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.of("+1")), JDBCType.TIMESTAMP_WITH_TIMEZONE); // } else { // st.setObject(index, ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.of("+1")), JDBCType.TIMESTAMP_WITH_TIMEZONE); // } } @Override protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException { final Timestamp timestamp = javaTypeDescriptor.unwrap(value, Timestamp.class, options); st.setObject(name, ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.of("+1"))); // if (st instanceof DruidPooledPreparedStatement) { // CallableStatement raw = (CallableStatement)((DruidPooledPreparedStatement)st).getRawPreparedStatement(); // raw.setObject(name, ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.of("+1")), JDBCType.TIMESTAMP_WITH_TIMEZONE); // } else { // st.setObject(name, ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.of("+1")), JDBCType.TIMESTAMP_WITH_TIMEZONE); // } } }; }
From source file:org.jadira.usertype.spi.shared.descriptor.sql.DstSafeTimestampTypeDescriptor.java
License:Apache License
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, (SqlTypeDescriptor) this) { @Override/*from w w w.j ava2 s . c om*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { if (cal == null) { st.setTimestamp(index, javaTypeDescriptor.unwrap(value, Timestamp.class, options)); } else { st.setTimestamp(index, javaTypeDescriptor.unwrap(value, Timestamp.class, options), cal); } } }; }
From source file:org.jadira.usertype.spi.shared.descriptor.sql.DstSafeTimeTypeDescriptor.java
License:Apache License
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, (SqlTypeDescriptor) this) { @Override/*from w w w . j av a 2 s.co m*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { if (cal == null) { st.setTime(index, javaTypeDescriptor.unwrap(value, Time.class, options)); } else { st.setTime(index, javaTypeDescriptor.unwrap(value, Time.class, options), cal); } } }; }
From source file:org.jasig.ssp.util.hibernate.SspDateTypeDescriptor.java
License:Apache License
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override//www .ja v a2s . com protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setDate(index, javaTypeDescriptor.unwrap(value, Date.class, options), Calendar.getInstance(SspTimeZones.INSTANCE.getDateOnlyDbTimeZone())); } }; }
From source file:org.jasig.ssp.util.hibernate.SspTimestampTypeDescriptor.java
License:Apache License
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override/*w w w. java 2 s. c o m*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setTimestamp(index, javaTypeDescriptor.unwrap(value, Timestamp.class, options), Calendar.getInstance(SspTimeZones.INSTANCE.getDbTimeZone())); } }; }
From source file:org.n52.series.db.ZonalTimestampTypeDescriptor.java
License:Open Source License
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override/*from w w w . java2 s . co m*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setTimestamp(index, javaTypeDescriptor.unwrap(value, Timestamp.class, options), zonalCalendar); } }; }
From source file:org.n52.sos.ds.hibernate.type.UtcTimestampTypeDescriptor.java
License:Open Source License
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override/*from w ww. jav a2s. c om*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setTimestamp(index, javaTypeDescriptor.unwrap(value, Timestamp.class, options), Calendar.getInstance(UTC)); } }; }
From source file:org.thingsboard.server.dao.util.mapping.JsonStringSqlTypeDescriptor.java
License:Apache License
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override/*from w ww . ja v a 2 s . co m*/ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setString(index, javaTypeDescriptor.unwrap(value, String.class, options)); } @Override protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException { st.setString(name, javaTypeDescriptor.unwrap(value, String.class, options)); } }; }
From source file:ru.caramel.juniperbot.core.common.persistence.types.json.JsonBinarySqlTypeDescriptor.java
License:Open Source License
@Override public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @Override//from ww w . ja v a 2 s . c om protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { st.setObject(index, javaTypeDescriptor.unwrap(value, JsonNode.class, options), getSqlType()); } @Override protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException { st.setObject(name, javaTypeDescriptor.unwrap(value, JsonNode.class, options), getSqlType()); } }; }