HHH-10465 - Loss of precision in temporal JavaTypeDescriptor implementations

This commit is contained in:
Owen Farrell 2016-10-14 06:04:06 -04:00 committed by Vlad Mihalcea
parent 886ea603de
commit ac22294bb3
4 changed files with 70 additions and 2 deletions

View File

@ -23,7 +23,7 @@ import org.hibernate.type.descriptor.WrapperOptions;
*/
public class JdbcTimeTypeDescriptor extends AbstractTypeDescriptor<Date> {
public static final JdbcTimeTypeDescriptor INSTANCE = new JdbcTimeTypeDescriptor();
public static final String TIME_FORMAT = "HH:mm:ss";
public static final String TIME_FORMAT = "HH:mm:ss.SSS";
public static class TimeMutabilityPlan extends MutableMutabilityPlan<Date> {
public static final TimeMutabilityPlan INSTANCE = new TimeMutabilityPlan();

View File

@ -23,7 +23,7 @@ import org.hibernate.type.descriptor.WrapperOptions;
*/
public class JdbcTimestampTypeDescriptor extends AbstractTypeDescriptor<Date> {
public static final JdbcTimestampTypeDescriptor INSTANCE = new JdbcTimestampTypeDescriptor();
public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
public static class TimestampMutabilityPlan extends MutableMutabilityPlan<Date> {
public static final TimestampMutabilityPlan INSTANCE = new TimestampMutabilityPlan();

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.type.descriptor.java;
import java.util.Date;
import org.hibernate.type.descriptor.java.JdbcTimeTypeDescriptor;
/**
* @author Owen Farrell
*/
public class JdbcTimeTypeDescriptorTest extends AbstractDescriptorTest<Date> {
final Date original = new Date();
final Date copy = new Date( original.getTime() );
final Date different = new Date( original.getTime() + 500L);
public JdbcTimeTypeDescriptorTest() {
super( JdbcTimeTypeDescriptor.INSTANCE );
}
@Override
protected Data<Date> getTestData() {
return new Data<Date>( original, copy, different );
}
@Override
protected boolean shouldBeMutable() {
return true;
}
}

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.type.descriptor.java;
import java.util.Date;
import org.hibernate.type.descriptor.java.JdbcTimestampTypeDescriptor;
/**
* @author Owen Farrell
*/
public class JdbcTimestampTypeDescriptorTest extends AbstractDescriptorTest<Date> {
final Date original = new Date();
final Date copy = new Date( original.getTime() );
final Date different = new Date( original.getTime() + 500L);
public JdbcTimestampTypeDescriptorTest() {
super( JdbcTimestampTypeDescriptor.INSTANCE );
}
@Override
protected Data<Date> getTestData() {
return new Data<Date>( original, copy, different );
}
@Override
protected boolean shouldBeMutable() {
return true;
}
}