Search in sources :

Example 6 with SybaseASE15Dialect

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

the class LongStringTest method testBoundedLongStringAccess.

@Test
public void testBoundedLongStringAccess() {
    Session s = openSession();
    s.beginTransaction();
    LongStringHolder entity = new LongStringHolder();
    s.save(entity);
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.beginTransaction();
    entity = s.get(LongStringHolder.class, entity.getId());
    assertNull(entity.getLongString());
    entity.setLongString(original);
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.beginTransaction();
    entity = s.get(LongStringHolder.class, entity.getId());
    assertEquals(LONG_STRING_SIZE, entity.getLongString().length());
    assertEquals(original, entity.getLongString());
    entity.setLongString(changed);
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.beginTransaction();
    entity = s.get(LongStringHolder.class, entity.getId());
    assertEquals(LONG_STRING_SIZE, entity.getLongString().length());
    assertEquals(changed, entity.getLongString());
    entity.setLongString(null);
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.beginTransaction();
    entity = s.get(LongStringHolder.class, entity.getId());
    assertNull(entity.getLongString());
    entity.setLongString(EMPTY);
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.beginTransaction();
    entity = s.get(LongStringHolder.class, entity.getId());
    if (entity.getLongString() != null) {
        if (getDialect() instanceof SybaseASE15Dialect) {
            //Sybase uses a single blank to denote an EMPTY string (this is by design). So, when inserting an EMPTY string '', it is interpreted as single blank ' '.
            assertEquals(EMPTY.length(), entity.getLongString().trim().length());
            assertEquals(EMPTY, entity.getLongString().trim());
        } else {
            assertEquals(EMPTY.length(), entity.getLongString().length());
            assertEquals(EMPTY, entity.getLongString());
        }
    }
    s.delete(entity);
    s.getTransaction().commit();
    s.close();
}
Also used : SybaseASE15Dialect(org.hibernate.dialect.SybaseASE15Dialect) Session(org.hibernate.Session) Test(org.junit.Test)

Example 7 with SybaseASE15Dialect

use of org.hibernate.dialect.SybaseASE15Dialect 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

SybaseASE15Dialect (org.hibernate.dialect.SybaseASE15Dialect)7 Session (org.hibernate.Session)5 Test (org.junit.Test)5 Transaction (org.hibernate.Transaction)3 DB2Dialect (org.hibernate.dialect.DB2Dialect)3 Oracle8iDialect (org.hibernate.dialect.Oracle8iDialect)3 Sybase11Dialect (org.hibernate.dialect.Sybase11Dialect)3 SybaseAnywhereDialect (org.hibernate.dialect.SybaseAnywhereDialect)3 SybaseDialect (org.hibernate.dialect.SybaseDialect)3 Date (java.util.Date)2 DerbyDialect (org.hibernate.dialect.DerbyDialect)2 HSQLDialect (org.hibernate.dialect.HSQLDialect)2 MySQL5Dialect (org.hibernate.dialect.MySQL5Dialect)2 MySQLDialect (org.hibernate.dialect.MySQLDialect)2 PostgreSQL81Dialect (org.hibernate.dialect.PostgreSQL81Dialect)2 SQLServerDialect (org.hibernate.dialect.SQLServerDialect)2 TeradataDialect (org.hibernate.dialect.TeradataDialect)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1