InstantTest, LocalDateTimeTest, OffsetDateTimeTest, ZonedDateTimeTest failing on Sybase for year 1600

Description

Stacktraces are similar to:

javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1489)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:512)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3321)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2517)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104)
at org.hibernate.testing.transaction.TransactionUtil2.inTransaction(TransactionUtil2.java:113)
at org.hibernate.testing.transaction.TransactionUtil2.lambda$inTransaction$0(TransactionUtil2.java:61)
at org.hibernate.testing.transaction.TransactionUtil2.inSession(TransactionUtil2.java:35)
at org.hibernate.testing.transaction.TransactionUtil2.inTransaction(TransactionUtil2.java:59)
at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.inTransaction(BaseCoreFunctionalTestCase.java:511)
at org.hibernate.test.type.AbstractJavaTimeTypeTest.lambda$writeThenRead$3(AbstractJavaTimeTypeTest.java:123)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.exception.GenericJDBCException: could not execute statement
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3205)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3719)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1483)
... 19 more
Caused by: com.sybase.jdbc4.jdbc.SybSQLException: Arithmetic overflow during implicit conversion of BIGDATETIME value 'Jan 1 1600 12:00AM' to a DATETIME field .

at com.sybase.jdbc4.tds.Tds.processEed(Tds.java:4003)
at com.sybase.jdbc4.tds.Tds.nextResult(Tds.java:3093)
at com.sybase.jdbc4.jdbc.ResultGetter.nextResult(ResultGetter.java:78)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:289)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:271)
at com.sybase.jdbc4.jdbc.SybStatement.updateLoop(SybStatement.java:2514)
at com.sybase.jdbc4.jdbc.SybStatement.executeUpdate(SybStatement.java:2498)
at com.sybase.jdbc4.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:296)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
... 27 more

Environment

None

Activity

Show:
Gail Badner
August 13, 2019, 3:46 AM
Edited

From Sybase documentation:

  • “datetime columns hold dates between January 1, 1753 and December 31, 9999. datetime values are accurate to 1/300 second on platforms that support this level of granularity. Storage size is 8 bytes: 4 bytes for the number of days since the base date of January 1, 1900 and 4 bytes for the time of day.

  • smalldatetime columns hold dates from January 1, 1900 to June 6, 2079, with accuracy to the minute. Its storage size is 4 bytes: 2 bytes for the number of days after January 1, 1900, and 2 bytes for the number of minutes after midnight.

  • bigdatetime columns hold dates from January 1, 0001 to December 31, 9999 and 12:00:00.000000 a.m. to 11:59:59.999999 p.m.. Its storage size is 8 bytes. bigdatetime values are accurate to a microsecond. The internal representation of bigdatetime is a 64-bit integer containing the number of microseconds since 01/01/0000.”

{{InstantType}} uses a {{TimestampTypeDescriptor}}, which is mapped to {{Types.TIMESTAMP}}.

For Sybase, {{Types.TIMESTAMP}} is mapped to {{datetime}} type.

All failures are for an {{Instant}} in the year 1600, which is why there is an arithmetic overflow.

For now, I will skip the tests involving the year 1600, since it is not valid for {{datetime}}.

Gail Badner
August 13, 2019, 4:33 AM

Fixed pushed upstream to master and 5.3 branches.

Waiting for confirmation from CI that tests are passing.

Gail Badner
August 13, 2019, 6:18 PM

Verified as fixed.

Assignee

Gail Badner

Reporter

Gail Badner

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure