List of usage examples for org.hibernate.type.descriptor.sql BasicBinder BasicBinder
public BasicBinder(JavaTypeDescriptor<J> javaDescriptor, SqlTypeDescriptor sqlDescriptor)
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 www .j a v a 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 www . ja va 2s . 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 ww w .j av a2 s . com 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 ww w.java 2 s. com 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//from www. jav a2 s. c o m 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/* ww w. j av a 2 s. 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(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.ja va 2 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 w w . j a v a2 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(UTC)); } }; }
From source file:org.teiid.hibernate.types.ArraySqlTypeDescriptor.java
License:Apache License
@Override public <X> ValueBinder<X> getBinder(JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, this) { @SuppressWarnings("unchecked") @Override// www . j a v a 2s .c o m protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { AbstractArrayTypeDescriptor<Object> abstractArrayTypeDescriptor = (AbstractArrayTypeDescriptor<Object>) javaTypeDescriptor; st.setArray(index, st.getConnection().createArrayOf(abstractArrayTypeDescriptor.getSqlArrayType(), abstractArrayTypeDescriptor.unwrap(value, Object[].class, options))); } @Override protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException { throw new UnsupportedOperationException("Binding by name is not supported!"); } }; }
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 w w. j a v a 2s .c o 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)); } }; }