HHH-15429 Fix loss of precision when serializing/deserializing arrays of doubles
This commit is contained in:
parent
4596c7f622
commit
23a487628a
|
@ -156,7 +156,7 @@ public class ArrayJdbcType implements JdbcType {
|
||||||
final TypeConfiguration typeConfiguration = options.getSessionFactory().getTypeConfiguration();
|
final TypeConfiguration typeConfiguration = options.getSessionFactory().getTypeConfiguration();
|
||||||
final JdbcType underlyingJdbcType = typeConfiguration.getJdbcTypeRegistry()
|
final JdbcType underlyingJdbcType = typeConfiguration.getJdbcTypeRegistry()
|
||||||
.getDescriptor( elementJdbcType.getDefaultSqlTypeCode() );
|
.getDescriptor( elementJdbcType.getDefaultSqlTypeCode() );
|
||||||
final Class<?> preferredJavaTypeClass = underlyingJdbcType.getPreferredJavaTypeClass( options );
|
final Class<?> preferredJavaTypeClass = elementJdbcType.getPreferredJavaTypeClass( options );
|
||||||
final Class<?> elementJdbcJavaTypeClass;
|
final Class<?> elementJdbcJavaTypeClass;
|
||||||
if ( preferredJavaTypeClass == null ) {
|
if ( preferredJavaTypeClass == null ) {
|
||||||
elementJdbcJavaTypeClass = underlyingJdbcType.getJdbcRecommendedJavaTypeMapping(
|
elementJdbcJavaTypeClass = underlyingJdbcType.getJdbcRecommendedJavaTypeMapping(
|
||||||
|
|
|
@ -60,6 +60,17 @@ public class DoubleArrayTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
q.setParameter( "id", 5L );
|
q.setParameter( "id", 5L );
|
||||||
q.setParameter( "data", new Double[]{ null, null, 0.0 } );
|
q.setParameter( "data", new Double[]{ null, null, 0.0 } );
|
||||||
q.executeUpdate();
|
q.executeUpdate();
|
||||||
|
|
||||||
|
em.persist( new TableWithDoubleArrays( 6L, new Double[]{ 0.12 } ) );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoadValueWithInexactFloatRepresentation() {
|
||||||
|
inSession( em -> {
|
||||||
|
TableWithDoubleArrays tableRecord;
|
||||||
|
tableRecord = em.find( TableWithDoubleArrays.class, 6L );
|
||||||
|
assertThat( tableRecord.getTheArray(), is( new Double[]{ 0.12 } ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue