Author: adamw
Date: 2009-11-25 03:35:22 -0500 (Wed, 25 Nov 2009)
New Revision: 18059
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
Log:
HHH-4608:
- options to specify default schema/catalog name for audit tables
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-11-25
08:01:22 UTC (rev 18058)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-11-25
08:35:22 UTC (rev 18059)
@@ -177,9 +177,9 @@
return true;
}
- private String getSchema(AuditTable auditTable, Table table) {
+ protected String getSchema(String schemaFromAnnotation, Table table) {
// Get the schema from the annotation ...
- String schema = auditTable.schema();
+ String schema = schemaFromAnnotation;
// ... if empty, try using the default ...
if (StringTools.isEmpty(schema)) {
schema = globalCfg.getDefaultSchemaName();
@@ -193,9 +193,9 @@
return schema;
}
- private String getCatalog(AuditTable auditTable, Table table) {
+ protected String getCatalog(String catalogFromAnnotation, Table table) {
// Get the catalog from the annotation ...
- String catalog = auditTable.catalog();
+ String catalog = catalogFromAnnotation;
// ... if empty, try using the default ...
if (StringTools.isEmpty(catalog)) {
catalog = globalCfg.getDefaultCatalogName();
@@ -232,8 +232,8 @@
auditTableName = verEntCfg.getAuditEntityName(originalTableName);
}
- String schema = getSchema(auditingData.getAuditTable(), join.getTable());
- String catalog = getCatalog(auditingData.getAuditTable(), join.getTable());
+ String schema = getSchema(auditingData.getAuditTable().schema(),
join.getTable());
+ String catalog = getCatalog(auditingData.getAuditTable().catalog(),
join.getTable());
Element joinElement = MetadataTools.createJoin(parent, auditTableName,
schema, catalog);
joinElements.put(join, joinElement);
@@ -311,8 +311,8 @@
@SuppressWarnings({"unchecked"})
public void generateFirstPass(PersistentClass pc, ClassAuditingData auditingData,
EntityXmlMappingData xmlMappingData, boolean isAudited)
{
- String schema = getSchema(auditingData.getAuditTable(), pc.getTable());
- String catalog = getCatalog(auditingData.getAuditTable(), pc.getTable());
+ String schema = getSchema(auditingData.getAuditTable().schema(), pc.getTable());
+ String catalog = getCatalog(auditingData.getAuditTable().catalog(),
pc.getTable());
if (!isAudited) {
String entityName = pc.getEntityName();
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-11-25
08:01:22 UTC (rev 18058)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-11-25
08:35:22 UTC (rev 18059)
@@ -475,10 +475,8 @@
}
private Element createMiddleEntityXml(String auditMiddleTableName, String
auditMiddleEntityName) {
- String schema = StringTools.isEmpty(propertyAuditingData.getJoinTable().schema())
?
- propertyValue.getCollectionTable().getSchema() :
propertyAuditingData.getJoinTable().schema();
- String catalog =
StringTools.isEmpty(propertyAuditingData.getJoinTable().catalog()) ?
- propertyValue.getCollectionTable().getCatalog() :
propertyAuditingData.getJoinTable().catalog();
+ String schema =
mainGenerator.getSchema(propertyAuditingData.getJoinTable().schema(),
propertyValue.getCollectionTable());
+ String catalog =
mainGenerator.getCatalog(propertyAuditingData.getJoinTable().catalog(),
propertyValue.getCollectionTable());
Element middleEntityXml =
MetadataTools.createEntity(xmlMappingData.newAdditionalMapping(),
new AuditTableData(auditMiddleEntityName, auditMiddleTableName, schema,
catalog), null);
Show replies by date