HHH-3570: changing default names
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15514 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
979f19bab8
commit
843d3c648f
|
@ -2,8 +2,8 @@
|
||||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
|
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
|
||||||
<persistence-unit name="ConsolePU">
|
<persistence-unit name="ConsolePU">
|
||||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||||
<class>org.hibernate.envers.envers.demo.Address</class>
|
<class>org.hibernate.envers.demo.Address</class>
|
||||||
<class>org.hibernate.envers.envers.demo.Person</class>
|
<class>org.hibernate.envers.demo.Person</class>
|
||||||
<exclude-unlisted-classes />
|
<exclude-unlisted-classes />
|
||||||
<properties>
|
<properties>
|
||||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
|
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
|
||||||
|
@ -22,9 +22,9 @@
|
||||||
<!--<property name="hibernate.show_sql" value="true"/>
|
<!--<property name="hibernate.show_sql" value="true"/>
|
||||||
<property name="hibernate.format_sql" value="true"/>-->
|
<property name="hibernate.format_sql" value="true"/>-->
|
||||||
|
|
||||||
<property name="hibernate.ejb.event.post-insert" value="org.hibernate.envers.envers.event.VersionsEventListener" />
|
<property name="hibernate.ejb.event.post-insert" value="org.hibernate.envers.event.AuditEventListener" />
|
||||||
<property name="hibernate.ejb.event.post-update" value="org.hibernate.envers.envers.event.VersionsEventListener" />
|
<property name="hibernate.ejb.event.post-update" value="org.hibernate.envers.event.AuditEventListener" />
|
||||||
<property name="hibernate.ejb.event.post-delete" value="org.hibernate.envers.envers.event.VersionsEventListener" />
|
<property name="hibernate.ejb.event.post-delete" value="org.hibernate.envers.event.AuditEventListener" />
|
||||||
</properties>
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
</persistence>
|
</persistence>
|
|
@ -50,14 +50,14 @@ public class AuditEntitiesConfiguration {
|
||||||
public AuditEntitiesConfiguration(Properties properties, String revisionInfoEntityName) {
|
public AuditEntitiesConfiguration(Properties properties, String revisionInfoEntityName) {
|
||||||
this.revisionInfoEntityName = revisionInfoEntityName;
|
this.revisionInfoEntityName = revisionInfoEntityName;
|
||||||
|
|
||||||
versionsTablePrefix = properties.getProperty("org.hibernate.envers.versionsTablePrefix", "");
|
versionsTablePrefix = properties.getProperty("org.hibernate.envers.auditTablePrefix", "");
|
||||||
versionsTableSuffix = properties.getProperty("org.hibernate.envers.versionsTableSuffix", "_versions");
|
versionsTableSuffix = properties.getProperty("org.hibernate.envers.auditTableSuffix", "_AUD");
|
||||||
|
|
||||||
originalIdPropName = "originalId";
|
originalIdPropName = "originalId";
|
||||||
|
|
||||||
revisionPropName = properties.getProperty("org.hibernate.envers.revisionFieldName", "_revision");
|
revisionPropName = properties.getProperty("org.hibernate.envers.revisionFieldName", "REV");
|
||||||
|
|
||||||
revisionTypePropName = properties.getProperty("org.hibernate.envers.revisionTypeFieldName", "_revision_type");
|
revisionTypePropName = properties.getProperty("org.hibernate.envers.revisionTypeFieldName", "REVTYPE");
|
||||||
revisionTypePropType = "byte";
|
revisionTypePropType = "byte";
|
||||||
|
|
||||||
customVersionsTablesNames = new HashMap<String, String>();
|
customVersionsTablesNames = new HashMap<String, String>();
|
||||||
|
|
|
@ -33,9 +33,6 @@ public class GlobalConfiguration {
|
||||||
// Should a revision be generated when a not-owned relation field changes
|
// Should a revision be generated when a not-owned relation field changes
|
||||||
private final boolean generateRevisionsForCollections;
|
private final boolean generateRevisionsForCollections;
|
||||||
|
|
||||||
// Should a warning, instead of an error and an exception, be logged, when an unsupported type is versioned
|
|
||||||
private final boolean warnOnUnsupportedTypes;
|
|
||||||
|
|
||||||
// Should the optimistic locking property of an entity be considered unversioned
|
// Should the optimistic locking property of an entity be considered unversioned
|
||||||
private final boolean unversionedOptimisticLockingField;
|
private final boolean unversionedOptimisticLockingField;
|
||||||
|
|
||||||
|
@ -52,12 +49,8 @@ public class GlobalConfiguration {
|
||||||
"true");
|
"true");
|
||||||
generateRevisionsForCollections = Boolean.parseBoolean(generateRevisionsForCollectionsStr);
|
generateRevisionsForCollections = Boolean.parseBoolean(generateRevisionsForCollectionsStr);
|
||||||
|
|
||||||
String warnOnUnsupportedTypesStr = properties.getProperty("org.hibernate.envers.warnOnUnsupportedTypes",
|
String ignoreOptimisticLockingPropertyStr = properties.getProperty("org.hibernate.envers.doNotAuditOptimisticLockingField",
|
||||||
"false");
|
"true");
|
||||||
warnOnUnsupportedTypes = Boolean.parseBoolean(warnOnUnsupportedTypesStr);
|
|
||||||
|
|
||||||
String ignoreOptimisticLockingPropertyStr = properties.getProperty("org.hibernate.envers.unversionedOptimisticLockingField",
|
|
||||||
"false");
|
|
||||||
unversionedOptimisticLockingField = Boolean.parseBoolean(ignoreOptimisticLockingPropertyStr);
|
unversionedOptimisticLockingField = Boolean.parseBoolean(ignoreOptimisticLockingPropertyStr);
|
||||||
|
|
||||||
correlatedSubqueryOperator = "org.hibernate.dialect.HSQLDialect".equals(
|
correlatedSubqueryOperator = "org.hibernate.dialect.HSQLDialect".equals(
|
||||||
|
@ -68,10 +61,6 @@ public class GlobalConfiguration {
|
||||||
return generateRevisionsForCollections;
|
return generateRevisionsForCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWarnOnUnsupportedTypes() {
|
|
||||||
return warnOnUnsupportedTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUnversionedOptimisticLockingField() {
|
public boolean isUnversionedOptimisticLockingField() {
|
||||||
return unversionedOptimisticLockingField;
|
return unversionedOptimisticLockingField;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,15 +71,15 @@ public class RevisionInfoConfiguration {
|
||||||
Element class_mapping = MetadataTools.createEntity(document, null, null, null, null, null);
|
Element class_mapping = MetadataTools.createEntity(document, null, null, null, null, null);
|
||||||
|
|
||||||
class_mapping.addAttribute("name", revisionInfoEntityName);
|
class_mapping.addAttribute("name", revisionInfoEntityName);
|
||||||
class_mapping.addAttribute("table", "_revisions_info");
|
class_mapping.addAttribute("table", "REVINFO");
|
||||||
|
|
||||||
Element idProperty = MetadataTools.addNativelyGeneratedId(class_mapping, revisionInfoIdData.getName(),
|
Element idProperty = MetadataTools.addNativelyGeneratedId(class_mapping, revisionInfoIdData.getName(),
|
||||||
revisionPropType);
|
revisionPropType);
|
||||||
MetadataTools.addColumn(idProperty, "revision_id", null);
|
MetadataTools.addColumn(idProperty, "REV", null);
|
||||||
|
|
||||||
Element timestampProperty = MetadataTools.addProperty(class_mapping, revisionInfoTimestampData.getName(),
|
Element timestampProperty = MetadataTools.addProperty(class_mapping, revisionInfoTimestampData.getName(),
|
||||||
revisionInfoTimestampType, true, false);
|
revisionInfoTimestampType, true, false);
|
||||||
MetadataTools.addColumn(timestampProperty, "revision_timestamp", null);
|
MetadataTools.addColumn(timestampProperty, "REVTSTMP", null);
|
||||||
|
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,6 @@ import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.ManyToOneType;
|
import org.hibernate.type.ManyToOneType;
|
||||||
import org.hibernate.type.OneToOneType;
|
import org.hibernate.type.OneToOneType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adam Warski (adam at warski dot org)
|
* @author Adam Warski (adam at warski dot org)
|
||||||
|
@ -71,8 +69,6 @@ public final class AuditMetadataGenerator {
|
||||||
// Map entity name -> (join descriptor -> element describing the "versioned" join)
|
// Map entity name -> (join descriptor -> element describing the "versioned" join)
|
||||||
private final Map<String, Map<Join, Element>> entitiesJoins;
|
private final Map<String, Map<Join, Element>> entitiesJoins;
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(AuditMetadataGenerator.class);
|
|
||||||
|
|
||||||
public AuditMetadataGenerator(Configuration cfg, GlobalConfiguration globalCfg,
|
public AuditMetadataGenerator(Configuration cfg, GlobalConfiguration globalCfg,
|
||||||
AuditEntitiesConfiguration verEntCfg,
|
AuditEntitiesConfiguration verEntCfg,
|
||||||
Element revisionInfoRelationMapping) {
|
Element revisionInfoRelationMapping) {
|
||||||
|
@ -340,10 +336,7 @@ public final class AuditMetadataGenerator {
|
||||||
void throwUnsupportedTypeException(Type type, String entityName, String propertyName) {
|
void throwUnsupportedTypeException(Type type, String entityName, String propertyName) {
|
||||||
String message = "Type not supported for versioning: " + type.getClass().getName() +
|
String message = "Type not supported for versioning: " + type.getClass().getName() +
|
||||||
", on entity " + entityName + ", property '" + propertyName + "'.";
|
", on entity " + entityName + ", property '" + propertyName + "'.";
|
||||||
if (globalCfg.isWarnOnUnsupportedTypes()) {
|
|
||||||
log.warn(message);
|
throw new MappingException(message);
|
||||||
} else {
|
|
||||||
throw new MappingException(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class BasicNaming extends AbstractEntityTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTableName() {
|
public void testTableName() {
|
||||||
assert "naming_test_entity_1_versions".equals(
|
assert "naming_test_entity_1_versions".equals(
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.NamingTestEntity1_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.NamingTestEntity1_AUD")
|
||||||
.getTable().getName());
|
.getTable().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class JoinNaming extends AbstractEntityTest {
|
||||||
@Test
|
@Test
|
||||||
public void testJoinColumnName() {
|
public void testJoinColumnName() {
|
||||||
Iterator<Column> columns =
|
Iterator<Column> columns =
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.JoinNamingRefIngEntity_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.JoinNamingRefIngEntity_AUD")
|
||||||
.getProperty("reference").getColumnIterator();
|
.getProperty("reference").getColumnIterator();
|
||||||
|
|
||||||
while (columns.hasNext()) {
|
while (columns.hasNext()) {
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class OneToManyUnidirectionalNaming extends AbstractEntityTest {
|
||||||
assert "data1".equals(rev2.getData());
|
assert "data1".equals(rev2.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String MIDDLE_VERSIONS_ENTITY_NAME = "UNI_NAMING_TEST_versions";
|
private final static String MIDDLE_VERSIONS_ENTITY_NAME = "UNI_NAMING_TEST_AUD";
|
||||||
@Test
|
@Test
|
||||||
public void testTableName() {
|
public void testTableName() {
|
||||||
assert MIDDLE_VERSIONS_ENTITY_NAME.equals(
|
assert MIDDLE_VERSIONS_ENTITY_NAME.equals(
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class JoinEmbIdNaming extends AbstractEntityTest {
|
||||||
@Test
|
@Test
|
||||||
public void testJoinColumnNames() {
|
public void testJoinColumnNames() {
|
||||||
Iterator<Column> columns =
|
Iterator<Column> columns =
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.ids.JoinEmbIdNamingRefIngEntity_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.ids.JoinEmbIdNamingRefIngEntity_AUD")
|
||||||
.getProperty("reference").getColumnIterator();
|
.getProperty("reference").getColumnIterator();
|
||||||
|
|
||||||
boolean xxFound = false;
|
boolean xxFound = false;
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class JoinMulIdNaming extends AbstractEntityTest {
|
||||||
@Test
|
@Test
|
||||||
public void testJoinColumnNames() {
|
public void testJoinColumnNames() {
|
||||||
Iterator<Column> columns =
|
Iterator<Column> columns =
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.ids.JoinMulIdNamingRefIngEntity_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.naming.ids.JoinMulIdNamingRefIngEntity_AUD")
|
||||||
.getProperty("reference").getColumnIterator();
|
.getProperty("reference").getColumnIterator();
|
||||||
|
|
||||||
boolean id1Found = false;
|
boolean id1Found = false;
|
||||||
|
|
|
@ -44,7 +44,7 @@ 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.unversionedOptimisticLockingField", "true");
|
cfg.setProperty("org.hibernate.envers.doNotAuditOptimisticLockingField", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass(dependsOnMethods = "init")
|
@BeforeClass(dependsOnMethods = "init")
|
||||||
|
@ -82,7 +82,7 @@ public class UnversionedOptimisticLockingField extends AbstractEntityTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMapping() {
|
public void testMapping() {
|
||||||
PersistentClass pc = getCfg().getClassMapping(UnversionedOptimisticLockingFieldEntity.class.getName() + "_versions");
|
PersistentClass pc = getCfg().getClassMapping(UnversionedOptimisticLockingFieldEntity.class.getName() + "_AUD");
|
||||||
Iterator pi = pc.getPropertyIterator();
|
Iterator pi = pc.getPropertyIterator();
|
||||||
while(pi.hasNext()) {
|
while(pi.hasNext()) {
|
||||||
Property p = (Property) pi.next();
|
Property p = (Property) pi.next();
|
||||||
|
|
|
@ -41,9 +41,8 @@ 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.versionsTablePrefix", "VP_");
|
cfg.setProperty("org.hibernate.envers.auditTablePrefix", "VP_");
|
||||||
cfg.setProperty("org.hibernate.envers.versionsTableSuffix", "_VS");
|
cfg.setProperty("org.hibernate.envers.auditTableSuffix", "_VS");
|
||||||
cfg.setProperty("org.hibernate.envers.idFieldName", "ver_id");
|
|
||||||
cfg.setProperty("org.hibernate.envers.revisionFieldName", "ver_rev");
|
cfg.setProperty("org.hibernate.envers.revisionFieldName", "ver_rev");
|
||||||
cfg.setProperty("org.hibernate.envers.revisionTypeFieldName", "ver_rev_type");
|
cfg.setProperty("org.hibernate.envers.revisionTypeFieldName", "ver_rev_type");
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,8 @@ public class BasicSecondary extends AbstractEntityTest {
|
||||||
@SuppressWarnings({"unchecked"})
|
@SuppressWarnings({"unchecked"})
|
||||||
@Test
|
@Test
|
||||||
public void testTableNames() {
|
public void testTableNames() {
|
||||||
assert "secondary_versions".equals(((Iterator<Join>)
|
assert "secondary_AUD".equals(((Iterator<Join>)
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.SecondaryTestEntity_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.SecondaryTestEntity_AUD")
|
||||||
.getJoinIterator())
|
.getJoinIterator())
|
||||||
.next().getTable().getName());
|
.next().getTable().getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class NamingSecondary extends AbstractEntityTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTableNames() {
|
public void testTableNames() {
|
||||||
assert "sec_versions".equals(((Iterator<Join>)
|
assert "sec_versions".equals(((Iterator<Join>)
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.SecondaryNamingTestEntity_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.SecondaryNamingTestEntity_AUD")
|
||||||
.getJoinIterator())
|
.getJoinIterator())
|
||||||
.next().getTable().getName());
|
.next().getTable().getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class EmbIdSecondary extends AbstractEntityTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTableNames() {
|
public void testTableNames() {
|
||||||
assert "sec_embid_versions".equals(((Iterator<Join>)
|
assert "sec_embid_versions".equals(((Iterator<Join>)
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.ids.SecondaryEmbIdTestEntity_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.ids.SecondaryEmbIdTestEntity_AUD")
|
||||||
.getJoinIterator())
|
.getJoinIterator())
|
||||||
.next().getTable().getName());
|
.next().getTable().getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class MulIdSecondary extends AbstractEntityTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTableNames() {
|
public void testTableNames() {
|
||||||
assert "sec_mulid_versions".equals(((Iterator<Join>)
|
assert "sec_mulid_versions".equals(((Iterator<Join>)
|
||||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.ids.SecondaryMulIdTestEntity_versions")
|
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.ids.SecondaryMulIdTestEntity_AUD")
|
||||||
.getJoinIterator())
|
.getJoinIterator())
|
||||||
.next().getTable().getName());
|
.next().getTable().getName());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue