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-unit name="ConsolePU">
|
||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||
<class>org.hibernate.envers.envers.demo.Address</class>
|
||||
<class>org.hibernate.envers.envers.demo.Person</class>
|
||||
<class>org.hibernate.envers.demo.Address</class>
|
||||
<class>org.hibernate.envers.demo.Person</class>
|
||||
<exclude-unlisted-classes />
|
||||
<properties>
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
|
||||
|
@ -22,9 +22,9 @@
|
|||
<!--<property name="hibernate.show_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-update" value="org.hibernate.envers.envers.event.VersionsEventListener" />
|
||||
<property name="hibernate.ejb.event.post-delete" 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.event.AuditEventListener" />
|
||||
<property name="hibernate.ejb.event.post-delete" value="org.hibernate.envers.event.AuditEventListener" />
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
|
@ -50,14 +50,14 @@ public class AuditEntitiesConfiguration {
|
|||
public AuditEntitiesConfiguration(Properties properties, String revisionInfoEntityName) {
|
||||
this.revisionInfoEntityName = revisionInfoEntityName;
|
||||
|
||||
versionsTablePrefix = properties.getProperty("org.hibernate.envers.versionsTablePrefix", "");
|
||||
versionsTableSuffix = properties.getProperty("org.hibernate.envers.versionsTableSuffix", "_versions");
|
||||
versionsTablePrefix = properties.getProperty("org.hibernate.envers.auditTablePrefix", "");
|
||||
versionsTableSuffix = properties.getProperty("org.hibernate.envers.auditTableSuffix", "_AUD");
|
||||
|
||||
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";
|
||||
|
||||
customVersionsTablesNames = new HashMap<String, String>();
|
||||
|
|
|
@ -33,9 +33,6 @@ public class GlobalConfiguration {
|
|||
// Should a revision be generated when a not-owned relation field changes
|
||||
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
|
||||
private final boolean unversionedOptimisticLockingField;
|
||||
|
||||
|
@ -52,12 +49,8 @@ public class GlobalConfiguration {
|
|||
"true");
|
||||
generateRevisionsForCollections = Boolean.parseBoolean(generateRevisionsForCollectionsStr);
|
||||
|
||||
String warnOnUnsupportedTypesStr = properties.getProperty("org.hibernate.envers.warnOnUnsupportedTypes",
|
||||
"false");
|
||||
warnOnUnsupportedTypes = Boolean.parseBoolean(warnOnUnsupportedTypesStr);
|
||||
|
||||
String ignoreOptimisticLockingPropertyStr = properties.getProperty("org.hibernate.envers.unversionedOptimisticLockingField",
|
||||
"false");
|
||||
String ignoreOptimisticLockingPropertyStr = properties.getProperty("org.hibernate.envers.doNotAuditOptimisticLockingField",
|
||||
"true");
|
||||
unversionedOptimisticLockingField = Boolean.parseBoolean(ignoreOptimisticLockingPropertyStr);
|
||||
|
||||
correlatedSubqueryOperator = "org.hibernate.dialect.HSQLDialect".equals(
|
||||
|
@ -68,10 +61,6 @@ public class GlobalConfiguration {
|
|||
return generateRevisionsForCollections;
|
||||
}
|
||||
|
||||
public boolean isWarnOnUnsupportedTypes() {
|
||||
return warnOnUnsupportedTypes;
|
||||
}
|
||||
|
||||
public boolean isUnversionedOptimisticLockingField() {
|
||||
return unversionedOptimisticLockingField;
|
||||
}
|
||||
|
|
|
@ -71,15 +71,15 @@ public class RevisionInfoConfiguration {
|
|||
Element class_mapping = MetadataTools.createEntity(document, null, null, null, null, null);
|
||||
|
||||
class_mapping.addAttribute("name", revisionInfoEntityName);
|
||||
class_mapping.addAttribute("table", "_revisions_info");
|
||||
class_mapping.addAttribute("table", "REVINFO");
|
||||
|
||||
Element idProperty = MetadataTools.addNativelyGeneratedId(class_mapping, revisionInfoIdData.getName(),
|
||||
revisionPropType);
|
||||
MetadataTools.addColumn(idProperty, "revision_id", null);
|
||||
MetadataTools.addColumn(idProperty, "REV", null);
|
||||
|
||||
Element timestampProperty = MetadataTools.addProperty(class_mapping, revisionInfoTimestampData.getName(),
|
||||
revisionInfoTimestampType, true, false);
|
||||
MetadataTools.addColumn(timestampProperty, "revision_timestamp", null);
|
||||
MetadataTools.addColumn(timestampProperty, "REVTSTMP", null);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,6 @@ import org.hibernate.type.CollectionType;
|
|||
import org.hibernate.type.ManyToOneType;
|
||||
import org.hibernate.type.OneToOneType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* @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)
|
||||
private final Map<String, Map<Join, Element>> entitiesJoins;
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(AuditMetadataGenerator.class);
|
||||
|
||||
public AuditMetadataGenerator(Configuration cfg, GlobalConfiguration globalCfg,
|
||||
AuditEntitiesConfiguration verEntCfg,
|
||||
Element revisionInfoRelationMapping) {
|
||||
|
@ -340,10 +336,7 @@ public final class AuditMetadataGenerator {
|
|||
void throwUnsupportedTypeException(Type type, String entityName, String propertyName) {
|
||||
String message = "Type not supported for versioning: " + type.getClass().getName() +
|
||||
", on entity " + entityName + ", property '" + propertyName + "'.";
|
||||
if (globalCfg.isWarnOnUnsupportedTypes()) {
|
||||
log.warn(message);
|
||||
} else {
|
||||
throw new MappingException(message);
|
||||
}
|
||||
|
||||
throw new MappingException(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public class BasicNaming extends AbstractEntityTest {
|
|||
@Test
|
||||
public void testTableName() {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public class JoinNaming extends AbstractEntityTest {
|
|||
@Test
|
||||
public void testJoinColumnName() {
|
||||
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();
|
||||
|
||||
while (columns.hasNext()) {
|
||||
|
|
|
@ -99,7 +99,7 @@ public class OneToManyUnidirectionalNaming extends AbstractEntityTest {
|
|||
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
|
||||
public void testTableName() {
|
||||
assert MIDDLE_VERSIONS_ENTITY_NAME.equals(
|
||||
|
|
|
@ -121,7 +121,7 @@ public class JoinEmbIdNaming extends AbstractEntityTest {
|
|||
@Test
|
||||
public void testJoinColumnNames() {
|
||||
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();
|
||||
|
||||
boolean xxFound = false;
|
||||
|
|
|
@ -121,7 +121,7 @@ public class JoinMulIdNaming extends AbstractEntityTest {
|
|||
@Test
|
||||
public void testJoinColumnNames() {
|
||||
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();
|
||||
|
||||
boolean id1Found = false;
|
||||
|
|
|
@ -44,7 +44,7 @@ public class UnversionedOptimisticLockingField extends AbstractEntityTest {
|
|||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(UnversionedOptimisticLockingFieldEntity.class);
|
||||
|
||||
cfg.setProperty("org.hibernate.envers.unversionedOptimisticLockingField", "true");
|
||||
cfg.setProperty("org.hibernate.envers.doNotAuditOptimisticLockingField", "true");
|
||||
}
|
||||
|
||||
@BeforeClass(dependsOnMethods = "init")
|
||||
|
@ -82,7 +82,7 @@ public class UnversionedOptimisticLockingField extends AbstractEntityTest {
|
|||
|
||||
@Test
|
||||
public void testMapping() {
|
||||
PersistentClass pc = getCfg().getClassMapping(UnversionedOptimisticLockingFieldEntity.class.getName() + "_versions");
|
||||
PersistentClass pc = getCfg().getClassMapping(UnversionedOptimisticLockingFieldEntity.class.getName() + "_AUD");
|
||||
Iterator pi = pc.getPropertyIterator();
|
||||
while(pi.hasNext()) {
|
||||
Property p = (Property) pi.next();
|
||||
|
|
|
@ -41,9 +41,8 @@ public class VersionsProperties extends AbstractEntityTest {
|
|||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(PropertiesTestEntity.class);
|
||||
|
||||
cfg.setProperty("org.hibernate.envers.versionsTablePrefix", "VP_");
|
||||
cfg.setProperty("org.hibernate.envers.versionsTableSuffix", "_VS");
|
||||
cfg.setProperty("org.hibernate.envers.idFieldName", "ver_id");
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -87,8 +87,8 @@ public class BasicSecondary extends AbstractEntityTest {
|
|||
@SuppressWarnings({"unchecked"})
|
||||
@Test
|
||||
public void testTableNames() {
|
||||
assert "secondary_versions".equals(((Iterator<Join>)
|
||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.SecondaryTestEntity_versions")
|
||||
assert "secondary_AUD".equals(((Iterator<Join>)
|
||||
getCfg().getClassMapping("org.hibernate.envers.test.integration.secondary.SecondaryTestEntity_AUD")
|
||||
.getJoinIterator())
|
||||
.next().getTable().getName());
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NamingSecondary extends AbstractEntityTest {
|
|||
@Test
|
||||
public void testTableNames() {
|
||||
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())
|
||||
.next().getTable().getName());
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class EmbIdSecondary extends AbstractEntityTest {
|
|||
@Test
|
||||
public void testTableNames() {
|
||||
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())
|
||||
.next().getTable().getName());
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class MulIdSecondary extends AbstractEntityTest {
|
|||
@Test
|
||||
public void testTableNames() {
|
||||
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())
|
||||
.next().getTable().getName());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue