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();
}
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());
}
}
}
}
Aggregations