HHH-7187 configurations should be defined in addConfigurationProperties method, instead configure
This commit is contained in:
parent
b2c4585921
commit
74e5c3150d
|
@ -1,5 +1,8 @@
|
||||||
package org.hibernate.envers.test.integration.flush;
|
package org.hibernate.envers.test.integration.flush;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.hibernate.FlushMode;
|
||||||
import org.hibernate.ejb.Ejb3Configuration;
|
import org.hibernate.ejb.Ejb3Configuration;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
||||||
|
@ -8,9 +11,10 @@ import org.hibernate.testing.TestForIssue;
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-7017")
|
@TestForIssue(jiraKey = "HHH-7017")
|
||||||
public class ManualFlushAutoCommitDisabled extends ManualFlush {
|
public class ManualFlushAutoCommitDisabled extends ManualFlush {
|
||||||
@Override
|
|
||||||
public void configure(Ejb3Configuration cfg) {
|
@Override
|
||||||
super.configure(cfg);
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
cfg.setProperty("hibernate.connection.autocommit", "false");
|
super.addConfigurationProperties( configuration );
|
||||||
}
|
configuration.setProperty("hibernate.connection.autocommit", "false");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ package org.hibernate.envers.test.integration.properties;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -44,7 +45,13 @@ public class UnversionedOptimisticLockingField extends AbstractEntityTest {
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
cfg.addAnnotatedClass(UnversionedOptimisticLockingFieldEntity.class);
|
cfg.addAnnotatedClass(UnversionedOptimisticLockingFieldEntity.class);
|
||||||
|
|
||||||
cfg.setProperty("org.hibernate.envers.doNotAuditOptimisticLockingField", "true");
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.doNotAuditOptimisticLockingField", "true");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
package org.hibernate.envers.test.integration.properties;
|
package org.hibernate.envers.test.integration.properties;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -41,13 +42,19 @@ public class VersionsProperties extends AbstractEntityTest {
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
cfg.addAnnotatedClass(PropertiesTestEntity.class);
|
cfg.addAnnotatedClass(PropertiesTestEntity.class);
|
||||||
|
|
||||||
cfg.setProperty("org.hibernate.envers.auditTablePrefix", "VP_");
|
|
||||||
cfg.setProperty("org.hibernate.envers.auditTableSuffix", "_VS");
|
|
||||||
cfg.setProperty("org.hibernate.envers.revisionFieldName", "ver_rev");
|
|
||||||
cfg.setProperty("org.hibernate.envers.revisionTypeFieldName", "ver_rev_type");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.auditTablePrefix", "VP_");
|
||||||
|
configuration.setProperty("org.hibernate.envers.auditTableSuffix", "_VS");
|
||||||
|
configuration.setProperty("org.hibernate.envers.revisionFieldName", "ver_rev");
|
||||||
|
configuration.setProperty("org.hibernate.envers.revisionTypeFieldName", "ver_rev_type");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Priority(10)
|
@Priority(10)
|
||||||
public void initData() {
|
public void initData() {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
package org.hibernate.envers.test.integration.query;
|
package org.hibernate.envers.test.integration.query;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -44,10 +45,16 @@ public class StoreDeletedData extends AbstractEntityTest {
|
||||||
|
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
cfg.addAnnotatedClass(StrIntTestEntity.class);
|
cfg.addAnnotatedClass(StrIntTestEntity.class);
|
||||||
cfg.setProperty("org.hibernate.envers.storeDataAtDelete", "true");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.storeDataAtDelete", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Priority(10)
|
@Priority(10)
|
||||||
public void initData() {
|
public void initData() {
|
||||||
// Revision 1
|
// Revision 1
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.hibernate.envers.test.integration.reventity;
|
package org.hibernate.envers.test.integration.reventity;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -18,10 +19,16 @@ import org.hibernate.testing.TestForIssue;
|
||||||
public class GloballyConfiguredRevListenerTest extends AbstractEntityTest {
|
public class GloballyConfiguredRevListenerTest extends AbstractEntityTest {
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
cfg.addAnnotatedClass(StrTestEntity.class);
|
cfg.addAnnotatedClass(StrTestEntity.class);
|
||||||
cfg.setProperty("org.hibernate.envers.revision_listener", "org.hibernate.envers.test.integration.reventity.CountingRevisionListener");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.revision_listener", "org.hibernate.envers.test.integration.reventity.CountingRevisionListener");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Priority(10)
|
@Priority(10)
|
||||||
public void initData() {
|
public void initData() {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.hibernate.envers.test.integration.reventity.trackmodifiedentities;
|
package org.hibernate.envers.test.integration.reventity.trackmodifiedentities;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.hibernate.ejb.Ejb3Configuration;
|
import org.hibernate.ejb.Ejb3Configuration;
|
||||||
import org.hibernate.envers.ModifiedEntityNames;
|
import org.hibernate.envers.ModifiedEntityNames;
|
||||||
import org.hibernate.envers.test.entities.reventity.trackmodifiedentities.AnnotatedTrackingRevisionEntity;
|
import org.hibernate.envers.test.entities.reventity.trackmodifiedentities.AnnotatedTrackingRevisionEntity;
|
||||||
|
@ -13,6 +15,12 @@ public class AnnotatedTrackingEntitiesTest extends DefaultTrackingEntitiesTest {
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
super.configure(cfg);
|
super.configure(cfg);
|
||||||
cfg.addAnnotatedClass(AnnotatedTrackingRevisionEntity.class);
|
cfg.addAnnotatedClass(AnnotatedTrackingRevisionEntity.class);
|
||||||
cfg.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.hibernate.envers.test.integration.reventity.trackmodifiedentities;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -31,12 +32,18 @@ public class DefaultTrackingEntitiesTest extends AbstractEntityTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
cfg.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "true");
|
|
||||||
cfg.addAnnotatedClass(StrTestEntity.class);
|
cfg.addAnnotatedClass(StrTestEntity.class);
|
||||||
cfg.addAnnotatedClass(StrIntTestEntity.class);
|
cfg.addAnnotatedClass(StrIntTestEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "true");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Priority(10)
|
@Priority(10)
|
||||||
public void initData() {
|
public void initData() {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.hibernate.envers.test.integration.reventity.trackmodifiedentities;
|
package org.hibernate.envers.test.integration.reventity.trackmodifiedentities;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.ejb.Ejb3Configuration;
|
import org.hibernate.ejb.Ejb3Configuration;
|
||||||
|
@ -16,10 +18,16 @@ public class ExtendedRevisionEntityTest extends DefaultTrackingEntitiesTest {
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
super.configure(cfg);
|
super.configure(cfg);
|
||||||
cfg.addAnnotatedClass(ExtendedRevisionEntity.class);
|
cfg.addAnnotatedClass(ExtendedRevisionEntity.class);
|
||||||
cfg.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "false");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCommentPropertyValue() {
|
public void testCommentPropertyValue() {
|
||||||
ExtendedRevisionEntity ere = getAuditReader().findRevision(ExtendedRevisionEntity.class, 1);
|
ExtendedRevisionEntity ere = getAuditReader().findRevision(ExtendedRevisionEntity.class, 1);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.hibernate.envers.test.integration.reventity.trackmodifiedentities;
|
package org.hibernate.envers.test.integration.reventity.trackmodifiedentities;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,7 +25,14 @@ public class TrackingEntitiesMultipleChangesTest extends AbstractEntityTest {
|
||||||
cfg.addAnnotatedClass(StrTestEntity.class);
|
cfg.addAnnotatedClass(StrTestEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
configuration.setProperty("org.hibernate.envers.track_entities_changed_in_revision", "true");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Priority(10)
|
@Priority(10)
|
||||||
public void initData() {
|
public void initData() {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.hibernate.envers.test.integration.strategy;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -33,12 +34,15 @@ public class ValidityAuditStrategyManyToManyTest extends AbstractEntityTest {
|
||||||
public void configure(Ejb3Configuration cfg) {
|
public void configure(Ejb3Configuration cfg) {
|
||||||
cfg.addAnnotatedClass(SetOwningEntity.class);
|
cfg.addAnnotatedClass(SetOwningEntity.class);
|
||||||
cfg.addAnnotatedClass(SetOwnedEntity.class);
|
cfg.addAnnotatedClass(SetOwnedEntity.class);
|
||||||
|
|
||||||
cfg.setProperty("org.hibernate.envers.audit_strategy",
|
|
||||||
"org.hibernate.envers.strategy.ValidityAuditStrategy");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
configuration.setProperty("org.hibernate.envers.audit_strategy",
|
||||||
|
"org.hibernate.envers.strategy.ValidityAuditStrategy");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Priority(10)
|
@Priority(10)
|
||||||
public void initData() {
|
public void initData() {
|
||||||
final EntityManager em = getEntityManager();
|
final EntityManager em = getEntityManager();
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
@ -68,17 +69,23 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends AbstractEntityT
|
||||||
cfg.addAnnotatedClass(Child1Entity.class);
|
cfg.addAnnotatedClass(Child1Entity.class);
|
||||||
cfg.addAnnotatedClass(Child2Entity.class);
|
cfg.addAnnotatedClass(Child2Entity.class);
|
||||||
cfg.addAnnotatedClass(CustomDateRevEntity.class);
|
cfg.addAnnotatedClass(CustomDateRevEntity.class);
|
||||||
|
}
|
||||||
|
|
||||||
cfg.setProperty("org.hibernate.envers.audit_strategy",
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
|
||||||
|
configuration.setProperty("org.hibernate.envers.audit_strategy",
|
||||||
"org.hibernate.envers.strategy.ValidityAuditStrategy");
|
"org.hibernate.envers.strategy.ValidityAuditStrategy");
|
||||||
cfg
|
configuration
|
||||||
.setProperty(
|
.setProperty(
|
||||||
"org.hibernate.envers.audit_strategy_validity_store_revend_timestamp",
|
"org.hibernate.envers.audit_strategy_validity_store_revend_timestamp",
|
||||||
"true");
|
"true");
|
||||||
cfg
|
configuration
|
||||||
.setProperty(
|
.setProperty(
|
||||||
"org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name",
|
"org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name",
|
||||||
revendTimestampColumName);
|
revendTimestampColumName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
@ -69,13 +70,19 @@ public class ValidityAuditStrategyRevEndTsTest extends AbstractEntityTest {
|
||||||
cfg.addAnnotatedClass(Child1Entity.class);
|
cfg.addAnnotatedClass(Child1Entity.class);
|
||||||
cfg.addAnnotatedClass(Child2Entity.class);
|
cfg.addAnnotatedClass(Child2Entity.class);
|
||||||
|
|
||||||
cfg.setProperty("org.hibernate.envers.audit_strategy",
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addConfigurationProperties(Properties configuration) {
|
||||||
|
super.addConfigurationProperties( configuration );
|
||||||
|
|
||||||
|
configuration.setProperty("org.hibernate.envers.audit_strategy",
|
||||||
"org.hibernate.envers.strategy.ValidityAuditStrategy");
|
"org.hibernate.envers.strategy.ValidityAuditStrategy");
|
||||||
cfg
|
configuration
|
||||||
.setProperty(
|
.setProperty(
|
||||||
"org.hibernate.envers.audit_strategy_validity_store_revend_timestamp",
|
"org.hibernate.envers.audit_strategy_validity_store_revend_timestamp",
|
||||||
"true");
|
"true");
|
||||||
cfg
|
configuration
|
||||||
.setProperty(
|
.setProperty(
|
||||||
"org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name",
|
"org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name",
|
||||||
revendTimestampColumName);
|
revendTimestampColumName);
|
||||||
|
|
|
@ -26,14 +26,15 @@ public class SchemaExportTest extends AbstractSessionTest {
|
||||||
protected void initMappings() throws MappingException, URISyntaxException {
|
protected void initMappings() throws MappingException, URISyntaxException {
|
||||||
config.addAnnotatedClass(StrTestEntity.class);
|
config.addAnnotatedClass(StrTestEntity.class);
|
||||||
// Disable schema auto generation.
|
// Disable schema auto generation.
|
||||||
config.setProperty(Environment.HBM2DDL_AUTO, "");
|
|
||||||
}
|
}
|
||||||
|
protected boolean createSchema() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@Test
|
@Test
|
||||||
@Priority(10)
|
@Priority(10)
|
||||||
public void testSchemaCreation() {
|
public void testSchemaCreation() {
|
||||||
// Generate complete schema.
|
// Generate complete schema.
|
||||||
new EnversSchemaGenerator(config).export().create(true, true);
|
new EnversSchemaGenerator(config).export().create( true, true );
|
||||||
|
|
||||||
// Populate database with test data.
|
// Populate database with test data.
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
|
@ -45,7 +46,13 @@ public class SchemaExportTest extends AbstractSessionTest {
|
||||||
id = entity.getId();
|
id = entity.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
|
public void closeSessionFactory() {
|
||||||
|
new EnversSchemaGenerator(config).export().drop( true, true );
|
||||||
|
super.closeSessionFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAuditDataRetrieval() {
|
public void testAuditDataRetrieval() {
|
||||||
Assert.assertEquals(Arrays.asList(1), getAuditReader().getRevisions(StrTestEntity.class, id));
|
Assert.assertEquals(Arrays.asList(1), getAuditReader().getRevisions(StrTestEntity.class, id));
|
||||||
Assert.assertEquals(new StrTestEntity("data", id), getAuditReader().find(StrTestEntity.class, id, 1));
|
Assert.assertEquals(new StrTestEntity("data", id), getAuditReader().find(StrTestEntity.class, id, 1));
|
||||||
|
|
Loading…
Reference in New Issue