HHH-7375 - TimeZone of Calendar objects should be used in binding to JDBC statements
This commit is contained in:
parent
9883d7b11a
commit
3e73948dae
|
@ -29,6 +29,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
|
@ -61,7 +62,13 @@ public class DateTypeDescriptor implements SqlTypeDescriptor {
|
|||
return new BasicBinder<X>( javaTypeDescriptor, this ) {
|
||||
@Override
|
||||
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
|
||||
st.setDate( index, javaTypeDescriptor.unwrap( value, Date.class, options ) );
|
||||
final Date date = javaTypeDescriptor.unwrap( value, Date.class, options );
|
||||
if ( value instanceof Calendar ) {
|
||||
st.setDate( index, date, (Calendar) value );
|
||||
}
|
||||
else {
|
||||
st.setDate( index, date );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,11 +24,13 @@
|
|||
package org.hibernate.type.descriptor.sql;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Date;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
import java.sql.Types;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
|
@ -61,7 +63,13 @@ public class TimeTypeDescriptor implements SqlTypeDescriptor {
|
|||
return new BasicBinder<X>( javaTypeDescriptor, this ) {
|
||||
@Override
|
||||
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
|
||||
st.setTime( index, javaTypeDescriptor.unwrap( value, Time.class, options ) );
|
||||
final Time time = javaTypeDescriptor.unwrap( value, Time.class, options );
|
||||
if ( value instanceof Calendar ) {
|
||||
st.setTime( index, time, (Calendar) value );
|
||||
}
|
||||
else {
|
||||
st.setTime( index, time );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
|
@ -61,7 +62,13 @@ public class TimestampTypeDescriptor implements SqlTypeDescriptor {
|
|||
return new BasicBinder<X>( javaTypeDescriptor, this ) {
|
||||
@Override
|
||||
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
|
||||
st.setTimestamp( index, javaTypeDescriptor.unwrap( value, Timestamp.class, options ) );
|
||||
final Timestamp timestamp = javaTypeDescriptor.unwrap( value, Timestamp.class, options );
|
||||
if ( value instanceof Calendar ) {
|
||||
st.setTimestamp( index, timestamp, (Calendar) value );
|
||||
}
|
||||
else {
|
||||
st.setTimestamp( index, timestamp );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue