HHH-7187 - Fix ValidityAuditStrategyRevEnd tests

This commit is contained in:
Lukasz Antoniak 2012-04-29 13:27:28 +02:00
parent a2bbe3cb53
commit 779e70df4d
2 changed files with 22 additions and 22 deletions

View File

@ -23,23 +23,19 @@
*/
package org.hibernate.envers.test.integration.strategy;
import java.sql.Types;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.hibernate.dialect.Oracle8iDialect;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.strategy.ValidityAuditStrategy;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
@ -95,17 +91,20 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
session.createSQLQuery("DROP TABLE children").executeUpdate();
session
.createSQLQuery(
"CREATE TABLE children(parent_id integer, child1_id integer NULL, child2_id integer NULL)")
"CREATE TABLE children ( parent_id " + getDialect().getTypeName(Types.INTEGER) +
", child1_id " + getDialect().getTypeName(Types.INTEGER) + " NULL" +
", child2_id " + getDialect().getTypeName(Types.INTEGER) + " NULL )")
.executeUpdate();
session.createSQLQuery("DROP TABLE children_AUD").executeUpdate();
session
.createSQLQuery(
"CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, "
+ revendTimestampColumName + " "
+ ((getDialect() instanceof SQLServerDialect || getDialect() instanceof SybaseASE15Dialect) ? "datetime" : "timestamp")
+ ", REVTYPE " + (getDialect() instanceof Oracle8iDialect ? "number(3,0)"
: (getDialect() instanceof PostgreSQL82Dialect ? "smallint" : "tinyint"))
+ ", parent_id integer, child1_id integer NULL, child2_id integer NULL)")
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName(Types.INTEGER) + " NOT NULL" +
", REVEND " + getDialect().getTypeName(Types.INTEGER) +
", " + revendTimestampColumName + " " + getDialect().getTypeName(Types.TIMESTAMP) +
", REVTYPE " + getDialect().getTypeName(Types.TINYINT) +
", parent_id " + getDialect().getTypeName(Types.INTEGER) +
", child1_id " + getDialect().getTypeName(Types.INTEGER) + " NULL" +
", child2_id " + getDialect().getTypeName(Types.INTEGER) + " NULL )")
.executeUpdate();
em.getTransaction().commit();
em.clear();

View File

@ -23,6 +23,7 @@
*/
package org.hibernate.envers.test.integration.strategy;
import java.sql.Types;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
@ -32,14 +33,11 @@ import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.hibernate.dialect.Oracle8iDialect;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
@ -96,17 +94,20 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
session.createSQLQuery("DROP TABLE children").executeUpdate();
session
.createSQLQuery(
"CREATE TABLE children(parent_id integer, child1_id integer NULL, child2_id integer NULL)")
"CREATE TABLE children ( parent_id " + getDialect().getTypeName(Types.INTEGER) +
", child1_id " + getDialect().getTypeName(Types.INTEGER) + " NULL" +
", child2_id " + getDialect().getTypeName(Types.INTEGER) + " NULL )")
.executeUpdate();
session.createSQLQuery("DROP TABLE children_AUD").executeUpdate();
session
.createSQLQuery(
"CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, "
+ revendTimestampColumName + " "
+ ((getDialect() instanceof SQLServerDialect || getDialect() instanceof SybaseASE15Dialect ) ? "datetime" : "timestamp")
+ ", REVTYPE " + (getDialect() instanceof Oracle8iDialect ? "number(3,0)"
: (getDialect() instanceof PostgreSQL82Dialect ? "smallint" : "tinyint"))
+ ", parent_id integer, child1_id integer NULL, child2_id integer NULL)")
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName(Types.INTEGER) + " NOT NULL" +
", REVEND " + getDialect().getTypeName(Types.INTEGER) +
", " + revendTimestampColumName + " " + getDialect().getTypeName(Types.TIMESTAMP) +
", REVTYPE " + getDialect().getTypeName(Types.TINYINT) +
", parent_id " + getDialect().getTypeName(Types.INTEGER) +
", child1_id " + getDialect().getTypeName(Types.INTEGER) + " NULL" +
", child2_id " + getDialect().getTypeName(Types.INTEGER) + " NULL )")
.executeUpdate();
em.getTransaction().commit();
em.clear();