Rounding of fractional seconds causes test failures on MySQL 5.6.4+

Description

The temporal datatypes 'TIME/DATETIME/TIMESTAMP' supports fractional values starting from MySQL 5.6.4 version.

See: http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

Without defining the number of fractional decimals it defaults to 0. In this case '2013-04-01 23:59:59.500' rounds to '2013-04-02 00:00:00'.

This affects tests in test suite:
example from:
org.hibernate.test.cid.CompositeIdWithGeneratorTest.testDetachedProperty

// change a non-id property, but do not persist Date persistedTimestamp = record.getTimestamp(); Date newTimestamp = new Date(persistedTimestamp.getTime() + 1); record.setTimestamp(newTimestamp); assertEquals( df.format(persistedTimestamp), df.format(found) );

There is more tests affected by this, I'll put list in comments

Activity

Show:

Former user January 5, 2015 at 9:24 PM

Closing in preparation for releasing 4.2.17.

Former user December 19, 2014 at 8:14 AM

Fixed by HHH-8401.

Former user December 17, 2014 at 6:24 AM

I've pushed the fix for HHH-8401. Using org.hibernate.dialect.MySQL57InnoDBDialect, the tests listed in this issue run successfully.

Former user October 24, 2014 at 6:28 AM

Please https://hibernate.atlassian.net/browse/HHH-8401#icft=HHH-8401 for comment about adding support for fractional seconds.

Martin Simka October 22, 2014 at 10:48 AM

affected test:
org.hibernate.test.cid.CompositeIdWithGeneratorTest.testDetachedProperty
org.hibernate.test.cid.CompositeIdWithGeneratorTest.testMerge
org.hibernate.test.cid.CompositeIdWithGeneratorTest.testDetachedId
org.hibernate.test.cid.CompositeIdWithGeneratorTest.testCompositeIdSimple
org.hibernate.test.cid.CompositeIdWithGeneratorTest.testEvict
org.hibernate.test.filter.DynamicFilterTest.testHQLSubqueryWithFilters
org.hibernate.test.filter.DynamicFilterTest.testCriteriaSubqueryWithFilters
org.hibernate.test.component.basic.ComponentTest.testComponent
org.hibernate.test.component.basic.ComponentTest.testComponentStateChangeAndDirtiness
org.hibernate.test.component.basic.ComponentTest.testCustomColumnReadAndWrite
org.hibernate.test.legacy.SQLLoaderTest.testTS
org.hibernate.test.legacy.SQLFunctionsTest.testBroken
org.hibernate.test.ops.MergeTest.testPersistThenMergeInSameTxnWithTimestamp
org.hibernate.test.stateless.StatelessSessionTest.testCreateUpdateReadDelete

There may be more tests affected, but so far I've found these tests. (although I'm not sure about some of them)

Gail, what can we do with these tests for 4.2 and overall current Hibernate behavior? Is it hard to add support for fractional seconds in mysql 5.6.4+?

Fixed

Details

Assignee

Reporter

Components

Affects versions

Priority

Created October 15, 2014 at 2:37 PM
Updated January 15, 2015 at 1:10 AM
Resolved December 19, 2014 at 8:14 AM

Flag notifications