Search in sources :

Example 1 with MySQL57Dialect

use of org.hibernate.dialect.MySQL57Dialect in project hibernate-orm by hibernate.

the class ValidityAuditStrategyRevEndTsTest method verifyRevEndTimeStamps.

private void verifyRevEndTimeStamps(String debugInfo, List<Map<String, Object>> revisionEntities) {
    for (Map<String, Object> revisionEntity : revisionEntities) {
        Date revendTimestamp = (Date) revisionEntity.get(revendTimestampColumName);
        SequenceIdRevisionEntity revEnd = (SequenceIdRevisionEntity) revisionEntity.get("REVEND");
        if (revendTimestamp == null) {
            Assert.assertNull(revEnd);
        } else {
            if (getDialect() instanceof MySQL5Dialect && !(getDialect() instanceof MySQL57Dialect || getDialect() instanceof MariaDB53Dialect)) {
                // MySQL5 DATETIME column type does not contain milliseconds.
                // MySQL 5.7 supports milliseconds and when MySQL57InnoDBDialect is used, it is assumed that
                // the column is defined as DATETIME(6).
                Assert.assertEquals(revendTimestamp.getTime(), (revEnd.getTimestamp() - (revEnd.getTimestamp() % 1000)));
            } else if (getDialect() instanceof SybaseASE15Dialect) {
                // Sybase "DATETIME values are accurate to 1/300 second on platforms that support this level of granularity".
                Assert.assertEquals(revendTimestamp.getTime() / 1000.0, revEnd.getTimestamp() / 1000.0, 1.0 / 300.0);
            } else {
                Assert.assertEquals(revendTimestamp.getTime(), revEnd.getTimestamp());
            }
        }
    }
}
Also used : MySQL57Dialect(org.hibernate.dialect.MySQL57Dialect) MySQL5Dialect(org.hibernate.dialect.MySQL5Dialect) MariaDB53Dialect(org.hibernate.dialect.MariaDB53Dialect) SybaseASE15Dialect(org.hibernate.dialect.SybaseASE15Dialect) SequenceIdRevisionEntity(org.hibernate.envers.enhanced.SequenceIdRevisionEntity) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 MariaDB53Dialect (org.hibernate.dialect.MariaDB53Dialect)1 MySQL57Dialect (org.hibernate.dialect.MySQL57Dialect)1 MySQL5Dialect (org.hibernate.dialect.MySQL5Dialect)1 SybaseASE15Dialect (org.hibernate.dialect.SybaseASE15Dialect)1 SequenceIdRevisionEntity (org.hibernate.envers.enhanced.SequenceIdRevisionEntity)1