HHH-7187 - Fixing tests on Sybase

This commit is contained in:
Lukasz Antoniak 2012-04-22 12:50:23 +02:00
parent cfa729d8b3
commit 6a7b70d4cc
4 changed files with 12 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
*/ */
@Embeddable @Embeddable
public class ManyToOneNotAuditedEmbId implements Serializable { public class ManyToOneNotAuditedEmbId implements Serializable {
@ManyToOne @ManyToOne(optional = false)
private UnversionedStrTestEntity id; private UnversionedStrTestEntity id;
public ManyToOneNotAuditedEmbId() { public ManyToOneNotAuditedEmbId() {

View File

@ -93,7 +93,8 @@ public class PartialModifiedFlagsEntity {
@Audited(withModifiedFlag = true) @Audited(withModifiedFlag = true)
@ManyToMany @ManyToMany
@CollectionTable(name = "ENTITIESMAP") @CollectionTable(name = "ENTITIESMAP")
@MapKeyColumn(nullable = false)
private Map<String, StrTestEntity> entitiesMap = private Map<String, StrTestEntity> entitiesMap =
new HashMap<String, StrTestEntity>(); new HashMap<String, StrTestEntity>();

View File

@ -39,6 +39,7 @@ import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.strategy.ValidityAuditStrategy; import org.hibernate.envers.strategy.ValidityAuditStrategy;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
@ -101,7 +102,7 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
.createSQLQuery( .createSQLQuery(
"CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, " "CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, "
+ revendTimestampColumName + " " + revendTimestampColumName + " "
+ (getDialect() instanceof SQLServerDialect ? "datetime" : "timestamp") + ((getDialect() instanceof SQLServerDialect || getDialect() instanceof SybaseASE15Dialect) ? "datetime" : "timestamp")
+ ", REVTYPE " + (getDialect() instanceof Oracle8iDialect ? "number(3,0)" + ", REVTYPE " + (getDialect() instanceof Oracle8iDialect ? "number(3,0)"
: (getDialect() instanceof PostgreSQL82Dialect ? "smallint" : "tinyint")) : (getDialect() instanceof PostgreSQL82Dialect ? "smallint" : "tinyint"))
+ ", parent_id integer, child1_id integer NULL, child2_id integer NULL)") + ", parent_id integer, child1_id integer NULL, child2_id integer NULL)")

View File

@ -40,6 +40,7 @@ import org.hibernate.Session;
import org.hibernate.dialect.MySQL5Dialect; import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
import org.hibernate.envers.strategy.ValidityAuditStrategy; import org.hibernate.envers.strategy.ValidityAuditStrategy;
@ -102,7 +103,7 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
.createSQLQuery( .createSQLQuery(
"CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, " "CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, "
+ revendTimestampColumName + " " + revendTimestampColumName + " "
+ (getDialect() instanceof SQLServerDialect ? "datetime" : "timestamp") + ((getDialect() instanceof SQLServerDialect || getDialect() instanceof SybaseASE15Dialect ) ? "datetime" : "timestamp")
+ ", REVTYPE " + (getDialect() instanceof Oracle8iDialect ? "number(3,0)" + ", REVTYPE " + (getDialect() instanceof Oracle8iDialect ? "number(3,0)"
: (getDialect() instanceof PostgreSQL82Dialect ? "smallint" : "tinyint")) : (getDialect() instanceof PostgreSQL82Dialect ? "smallint" : "tinyint"))
+ ", parent_id integer, child1_id integer NULL, child2_id integer NULL)") + ", parent_id integer, child1_id integer NULL, child2_id integer NULL)")
@ -431,6 +432,11 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
if (getDialect() instanceof MySQL5Dialect) { if (getDialect() instanceof MySQL5Dialect) {
// MySQL5 DATETIME column type does not contain milliseconds. // MySQL5 DATETIME column type does not contain milliseconds.
Assert.assertEquals(revendTimestamp.getTime(), (revEnd.getTimestamp() - (revEnd.getTimestamp() % 1000))); 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 { } else {
Assert.assertEquals(revendTimestamp.getTime(), revEnd.getTimestamp()); Assert.assertEquals(revendTimestamp.getTime(), revEnd.getTimestamp());
} }