Author: adamw
Date: 2008-11-05 04:13:05 -0500 (Wed, 05 Nov 2008)
New Revision: 15517
Added:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReader.java
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java
core/trunk/envers/src/main/java/org/hibernate/envers/NotAudited.java
core/trunk/envers/src/main/java/org/hibernate/envers/SecondaryAuditTable.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AnnotationsMetadataReader.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/QueryGeneratorBuilder.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/ToOneRelationMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MiddleIdData.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.java
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AddWorkUnit.java
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/CollectionChangeWorkUnit.java
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/DelWorkUnit.java
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/ModWorkUnit.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/SecondaryNamingTestEntity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryEmbIdTestEntity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryMulIdTestEntity.java
Log:
HHH-3570: more renaming
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/AuditReader.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/AuditReader.java 2008-11-05
08:59:14 UTC (rev 15516)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/AuditReader.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -40,7 +40,7 @@
* @param primaryKey Primary key of the entity.
* @param revision Revision in which to get the entity.
* @return The found entity instance at the given revision (its properties may be
partially filled
- * if not all properties are versioned) or null, if an entity with that id didn't
exist at that
+ * if not all properties are audited) or null, if an entity with that id didn't
exist at that
* revision.
* @throws IllegalArgumentException If cls or primaryKey is null or revision is less
or equal to 0.
* @throws NotAuditedException When entities of the given class are not audited.
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -42,11 +42,11 @@
private AuditReaderFactory() { }
/**
- * Create a versions reader associated with an open session.
+ * Create an audit reader associated with an open session.
* <b>WARNING:</b> Using Envers with Hibernate (not with Hibernate Entity
Manager/JPA) is experimental,
* if possible, use {@link AuditReaderFactory#get(javax.persistence.EntityManager)}.
* @param session An open session.
- * @return A versions reader associated with the given sesison. It shouldn't be
used
+ * @return An audit reader associated with the given sesison. It shouldn't be
used
* after the session is closed.
* @throws AuditException When the given required listeners aren't installed.
*/
@@ -70,9 +70,9 @@
}
/**
- * Create a versions reader associated with an open entity manager.
+ * Create an audit reader associated with an open entity manager.
* @param entityManager An open entity manager.
- * @return A versions reader associated with the given entity manager. It
shouldn't be used
+ * @return An audit reader associated with the given entity manager. It shouldn't
be used
* after the entity manager is closed.
* @throws AuditException When the given entity manager is not based on Hibernate, or
if the required
* listeners aren't installed.
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/NotAudited.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/NotAudited.java 2008-11-05
08:59:14 UTC (rev 15516)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/NotAudited.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -29,7 +29,7 @@
import java.lang.annotation.Target;
/**
- * When applied to a field, indicates that this field should not be versioned.
+ * When applied to a field, indicates that this field should not be audited.
* @author Sebastian Komander
*/
@Retention(RetentionPolicy.RUNTIME)
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/SecondaryAuditTable.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/SecondaryAuditTable.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/SecondaryAuditTable.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -36,5 +36,5 @@
public @interface SecondaryAuditTable {
String secondaryTableName();
- String secondaryVersionsTableName();
+ String secondaryAuditTableName();
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -32,8 +32,8 @@
* @author Adam Warski (adam at warski dot org)
*/
public class AuditEntitiesConfiguration {
- private final String versionsTablePrefix;
- private final String versionsTableSuffix;
+ private final String auditTablePrefix;
+ private final String auditTableSuffix;
private final String originalIdPropName;
@@ -45,13 +45,13 @@
private final String revisionInfoEntityName;
- private final Map<String, String> customVersionsTablesNames;
+ private final Map<String, String> customAuditTablesNames;
public AuditEntitiesConfiguration(Properties properties, String
revisionInfoEntityName) {
this.revisionInfoEntityName = revisionInfoEntityName;
- versionsTablePrefix =
properties.getProperty("org.hibernate.envers.auditTablePrefix", "");
- versionsTableSuffix =
properties.getProperty("org.hibernate.envers.auditTableSuffix",
"_AUD");
+ auditTablePrefix =
properties.getProperty("org.hibernate.envers.auditTablePrefix", "");
+ auditTableSuffix =
properties.getProperty("org.hibernate.envers.auditTableSuffix",
"_AUD");
originalIdPropName = "originalId";
@@ -60,7 +60,7 @@
revisionTypePropName =
properties.getProperty("org.hibernate.envers.revisionTypeFieldName",
"REVTYPE");
revisionTypePropType = "byte";
- customVersionsTablesNames = new HashMap<String, String>();
+ customAuditTablesNames = new HashMap<String, String>();
revisionPropPath = originalIdPropName + "." + revisionPropName +
".id";
}
@@ -91,20 +91,20 @@
//
- public void addCustomVersionsTableName(String entityName, String tableName) {
- customVersionsTablesNames.put(entityName, tableName);
+ public void addCustomAuditTableName(String entityName, String tableName) {
+ customAuditTablesNames.put(entityName, tableName);
}
//
- public String getVersionsEntityName(String entityName) {
- return versionsTablePrefix + entityName + versionsTableSuffix;
+ public String getAuditEntityName(String entityName) {
+ return auditTablePrefix + entityName + auditTableSuffix;
}
- public String getVersionsTableName(String entityName, String tableName) {
- String customHistoryTableName = customVersionsTablesNames.get(entityName);
+ public String getAuditTableName(String entityName, String tableName) {
+ String customHistoryTableName = customAuditTablesNames.get(entityName);
if (customHistoryTableName == null) {
- return versionsTablePrefix + tableName + versionsTableSuffix;
+ return auditTablePrefix + tableName + auditTableSuffix;
}
return customHistoryTableName;
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -57,7 +57,7 @@
public EntitiesConfigurations configure(Configuration cfg, ReflectionManager
reflectionManager,
GlobalConfiguration globalCfg,
AuditEntitiesConfiguration verEntCfg,
Document revisionInfoXmlMapping, Element
revisionInfoRelationMapping) {
- AuditMetadataGenerator versionsMetaGen = new AuditMetadataGenerator(cfg,
globalCfg, verEntCfg,
+ AuditMetadataGenerator auditMetaGen = new AuditMetadataGenerator(cfg, globalCfg,
verEntCfg,
revisionInfoRelationMapping);
DOMWriter writer = new DOMWriter();
@@ -80,11 +80,11 @@
pcDatas.put(pc, auditData);
if (!StringTools.isEmpty(auditData.getAuditTable().value())) {
- verEntCfg.addCustomVersionsTableName(pc.getEntityName(),
auditData.getAuditTable().value());
+ verEntCfg.addCustomAuditTableName(pc.getEntityName(),
auditData.getAuditTable().value());
}
EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
- versionsMetaGen.generateFirstPass(pc, auditData, xmlMappingData);
+ auditMetaGen.generateFirstPass(pc, auditData, xmlMappingData);
xmlMappings.put(pc, xmlMappingData);
}
}
@@ -93,7 +93,7 @@
for (Map.Entry<PersistentClass, PersistentClassAuditingData> pcDatasEntry :
pcDatas.entrySet()) {
EntityXmlMappingData xmlMappingData =
xmlMappings.get(pcDatasEntry.getKey());
- versionsMetaGen.generateSecondPass(pcDatasEntry.getKey(),
pcDatasEntry.getValue(), xmlMappingData);
+ auditMetaGen.generateSecondPass(pcDatasEntry.getKey(),
pcDatasEntry.getValue(), xmlMappingData);
try {
cfg.addDocument(writer.write(xmlMappingData.getMainXmlMapping()));
@@ -123,7 +123,7 @@
}
}
- return new EntitiesConfigurations(versionsMetaGen.getEntitiesConfigurations());
+ return new EntitiesConfigurations(auditMetaGen.getEntitiesConfigurations());
}
// todo
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -34,7 +34,7 @@
private final boolean generateRevisionsForCollections;
// Should the optimistic locking property of an entity be considered unversioned
- private final boolean unversionedOptimisticLockingField;
+ private final boolean doNotAuditOptimisticLockingField;
/*
Which operator to use in correlated subqueries (when we want a property to be equal
to the result of
@@ -51,7 +51,7 @@
String ignoreOptimisticLockingPropertyStr =
properties.getProperty("org.hibernate.envers.doNotAuditOptimisticLockingField",
"true");
- unversionedOptimisticLockingField =
Boolean.parseBoolean(ignoreOptimisticLockingPropertyStr);
+ doNotAuditOptimisticLockingField =
Boolean.parseBoolean(ignoreOptimisticLockingPropertyStr);
correlatedSubqueryOperator =
"org.hibernate.dialect.HSQLDialect".equals(
properties.getProperty("hibernate.dialect")) ? "in" :
"=";
@@ -61,8 +61,8 @@
return generateRevisionsForCollections;
}
- public boolean isUnversionedOptimisticLockingField() {
- return unversionedOptimisticLockingField;
+ public boolean isDoNotAuditOptimisticLockingField() {
+ return doNotAuditOptimisticLockingField;
}
public String getCorrelatedSubqueryOperator() {
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -177,7 +177,7 @@
throw new MappingException("Only one entity may be annotated
with @RevisionEntity!");
}
- // Checking if custom revision entity isn't versioned
+ // Checking if custom revision entity isn't audited
if (clazz.getAnnotation(Audited.class) != null) {
throw new MappingException("An entity annotated with
@RevisionEntity cannot be audited!");
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AnnotationsMetadataReader.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AnnotationsMetadataReader.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AnnotationsMetadataReader.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -111,7 +111,7 @@
} else {
// if the optimistic locking field has to be unversioned and the current
property
// is the optimistic locking field, don't audit it
- if (globalCfg.isUnversionedOptimisticLockingField()) {
+ if (globalCfg.isDoNotAuditOptimisticLockingField()) {
Version jpaVer = property.getAnnotation(Version.class);
if (jpaVer != null) {
return false;
@@ -206,7 +206,7 @@
}
}
- private void addVersionsTable(XClass clazz) {
+ private void addAuditTable(XClass clazz) {
AuditTable auditTable = clazz.getAnnotation(AuditTable.class);
if (auditTable != null) {
auditData.setAuditTable(auditTable);
@@ -215,19 +215,19 @@
}
}
- private void addVersionsSecondaryTables(XClass clazz) {
+ private void addAuditSecondaryTables(XClass clazz) {
// Getting information on secondary tables
SecondaryAuditTable secondaryVersionsTable1 =
clazz.getAnnotation(SecondaryAuditTable.class);
if (secondaryVersionsTable1 != null) {
auditData.getSecondaryTableDictionary().put(secondaryVersionsTable1.secondaryTableName(),
- secondaryVersionsTable1.secondaryVersionsTableName());
+ secondaryVersionsTable1.secondaryAuditTableName());
}
- SecondaryAuditTables secondaryVersionsTables =
clazz.getAnnotation(SecondaryAuditTables.class);
- if (secondaryVersionsTables != null) {
- for (SecondaryAuditTable secondaryVersionsTable2 :
secondaryVersionsTables.value()) {
-
auditData.getSecondaryTableDictionary().put(secondaryVersionsTable2.secondaryTableName(),
- secondaryVersionsTable2.secondaryVersionsTableName());
+ SecondaryAuditTables secondaryAuditTables =
clazz.getAnnotation(SecondaryAuditTables.class);
+ if (secondaryAuditTables != null) {
+ for (SecondaryAuditTable secondaryAuditTable2 : secondaryAuditTables.value())
{
+
auditData.getSecondaryTableDictionary().put(secondaryAuditTable2.secondaryTableName(),
+ secondaryAuditTable2.secondaryAuditTableName());
}
}
}
@@ -244,8 +244,8 @@
readDefaultAudited(clazz);
addPropertiesFromClass(clazz);
- addVersionsTable(clazz);
- addVersionsSecondaryTables(clazz);
+ addAuditTable(clazz);
+ addAuditSecondaryTables(clazz);
} catch (ClassNotFoundException e) {
throw new MappingException(e);
}
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 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -145,21 +145,21 @@
@SuppressWarnings({"unchecked"})
private void addProperties(Element parent, Iterator<Property> properties,
CompositeMapperBuilder currentMapper,
- PersistentClassAuditingData versioningData, String
entityName, EntityXmlMappingData xmlMappingData,
+ PersistentClassAuditingData auditingData, String
entityName, EntityXmlMappingData xmlMappingData,
boolean firstPass) {
while (properties.hasNext()) {
Property property = properties.next();
String propertyName = property.getName();
- if (versioningData.getPropertyAuditingData(propertyName) != null) {
+ if (auditingData.getPropertyAuditingData(propertyName) != null) {
addValue(parent, property.getValue(), currentMapper, entityName,
- xmlMappingData,
versioningData.getPropertyAuditingData(propertyName),
+ xmlMappingData,
auditingData.getPropertyAuditingData(propertyName),
property.isInsertable(), firstPass);
}
}
}
@SuppressWarnings({"unchecked"})
- private void createJoins(PersistentClass pc, Element parent,
PersistentClassAuditingData versioningData) {
+ private void createJoins(PersistentClass pc, Element parent,
PersistentClassAuditingData auditingData) {
Iterator<Join> joins = pc.getJoinIterator();
Map<Join, Element> joinElements = new HashMap<Join, Element>();
@@ -171,22 +171,22 @@
// Determining the table name. If there is no entry in the dictionary, just
constructing the table name
// as if it was an entity (by appending/prepending configured strings).
String originalTableName = join.getTable().getName();
- String versionedTableName =
versioningData.getSecondaryTableDictionary().get(originalTableName);
- if (versionedTableName == null) {
- versionedTableName = verEntCfg.getVersionsEntityName(originalTableName);
+ String auditTableName =
auditingData.getSecondaryTableDictionary().get(originalTableName);
+ if (auditTableName == null) {
+ auditTableName = verEntCfg.getAuditEntityName(originalTableName);
}
- String schema = versioningData.getAuditTable().schema();
+ String schema = auditingData.getAuditTable().schema();
if (StringTools.isEmpty(schema)) {
schema = join.getTable().getSchema();
}
- String catalog = versioningData.getAuditTable().catalog();
+ String catalog = auditingData.getAuditTable().catalog();
if (StringTools.isEmpty(catalog)) {
catalog = join.getTable().getCatalog();
}
- Element joinElement = MetadataTools.createJoin(parent, versionedTableName,
schema, catalog);
+ Element joinElement = MetadataTools.createJoin(parent, auditTableName,
schema, catalog);
joinElements.put(join, joinElement);
Element joinKey = joinElement.addElement("key");
@@ -196,7 +196,7 @@
}
@SuppressWarnings({"unchecked"})
- private void addJoins(PersistentClass pc, CompositeMapperBuilder currentMapper,
PersistentClassAuditingData versioningData,
+ private void addJoins(PersistentClass pc, CompositeMapperBuilder currentMapper,
PersistentClassAuditingData auditingData,
String entityName, EntityXmlMappingData xmlMappingData,boolean
firstPass) {
Iterator<Join> joins = pc.getJoinIterator();
@@ -204,27 +204,27 @@
Join join = joins.next();
Element joinElement = entitiesJoins.get(entityName).get(join);
- addProperties(joinElement, join.getPropertyIterator(), currentMapper,
versioningData, entityName,
+ addProperties(joinElement, join.getPropertyIterator(), currentMapper,
auditingData, entityName,
xmlMappingData, firstPass);
}
}
@SuppressWarnings({"unchecked"})
- public void generateFirstPass(PersistentClass pc, PersistentClassAuditingData
versioningData,
+ public void generateFirstPass(PersistentClass pc, PersistentClassAuditingData
auditingData,
EntityXmlMappingData xmlMappingData) {
- String schema = versioningData.getAuditTable().schema();
+ String schema = auditingData.getAuditTable().schema();
if (StringTools.isEmpty(schema)) {
schema = pc.getTable().getSchema();
}
- String catalog = versioningData.getAuditTable().catalog();
+ String catalog = auditingData.getAuditTable().catalog();
if (StringTools.isEmpty(catalog)) {
catalog = pc.getTable().getCatalog();
}
String entityName = pc.getEntityName();
- String versionsEntityName = verEntCfg.getVersionsEntityName(entityName);
- String versionsTableName = verEntCfg.getVersionsTableName(entityName,
pc.getTable().getName());
+ String auditEntityName = verEntCfg.getAuditEntityName(entityName);
+ String auditTableName = verEntCfg.getAuditTableName(entityName,
pc.getTable().getName());
// Generating a mapping for the id
IdMappingData idMapper = idMetadataGenerator.addId(pc);
@@ -237,7 +237,7 @@
switch (inheritanceType) {
case NONE:
- class_mapping =
MetadataTools.createEntity(xmlMappingData.getMainXmlMapping(), versionsEntityName,
versionsTableName,
+ class_mapping =
MetadataTools.createEntity(xmlMappingData.getMainXmlMapping(), auditEntityName,
auditTableName,
schema, catalog, pc.getDiscriminatorValue());
propertyMapper = new MultiPropertyMapper();
@@ -256,9 +256,9 @@
break;
case SINGLE:
- String extendsEntityName =
verEntCfg.getVersionsEntityName(pc.getSuperclass().getEntityName());
- class_mapping =
MetadataTools.createSubclassEntity(xmlMappingData.getMainXmlMapping(),
versionsEntityName,
- versionsTableName, schema, catalog, extendsEntityName,
pc.getDiscriminatorValue());
+ String extendsEntityName =
verEntCfg.getAuditEntityName(pc.getSuperclass().getEntityName());
+ class_mapping =
MetadataTools.createSubclassEntity(xmlMappingData.getMainXmlMapping(), auditEntityName,
+ auditTableName, schema, catalog, extendsEntityName,
pc.getDiscriminatorValue());
// The id and revision type is already mapped in the parent
@@ -269,30 +269,30 @@
break;
case JOINED:
- throw new MappingException("Joined inheritance strategy not
supported for versioning!");
+ throw new MappingException("Joined inheritance strategy not
supported for auditing!");
case TABLE_PER_CLASS:
- throw new MappingException("Table-per-class inheritance strategy not
supported for versioning!");
+ throw new MappingException("Table-per-class inheritance strategy not
supported for auditing!");
default:
throw new AssertionError("Impossible enum value.");
}
// Mapping unjoined properties
addProperties(class_mapping, (Iterator<Property>)
pc.getUnjoinedPropertyIterator(), propertyMapper,
- versioningData, pc.getEntityName(), xmlMappingData,
+ auditingData, pc.getEntityName(), xmlMappingData,
true);
// Creating and mapping joins (first pass)
- createJoins(pc, class_mapping, versioningData);
- addJoins(pc, propertyMapper, versioningData, pc.getEntityName(), xmlMappingData,
true);
+ createJoins(pc, class_mapping, auditingData);
+ addJoins(pc, propertyMapper, auditingData, pc.getEntityName(), xmlMappingData,
true);
// Storing the generated configuration
- EntityConfiguration entityCfg = new EntityConfiguration(versionsEntityName,
idMapper,
+ EntityConfiguration entityCfg = new EntityConfiguration(auditEntityName,
idMapper,
propertyMapper, parentEntityName);
entitiesConfigurations.put(pc.getEntityName(), entityCfg);
}
@SuppressWarnings({"unchecked"})
- public void generateSecondPass(PersistentClass pc, PersistentClassAuditingData
versioningData,
+ public void generateSecondPass(PersistentClass pc, PersistentClassAuditingData
auditingData,
EntityXmlMappingData xmlMappingData) {
String entityName = pc.getEntityName();
@@ -305,10 +305,10 @@
}
addProperties(parent, (Iterator<Property>)
pc.getUnjoinedPropertyIterator(),
- propertyMapper, versioningData, entityName, xmlMappingData, false);
+ propertyMapper, auditingData, entityName, xmlMappingData, false);
// Mapping joins (second pass)
- addJoins(pc, propertyMapper, versioningData, entityName, xmlMappingData, false);
+ addJoins(pc, propertyMapper, auditingData, entityName, xmlMappingData, false);
}
public Map<String, EntityConfiguration> getEntitiesConfigurations() {
@@ -334,7 +334,7 @@
}
void throwUnsupportedTypeException(Type type, String entityName, String propertyName)
{
- String message = "Type not supported for versioning: " +
type.getClass().getName() +
+ String message = "Type not supported for auditing: " +
type.getClass().getName() +
", on entity " + entityName + ", property '" +
propertyName + "'.";
throw new MappingException(message);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -151,7 +151,7 @@
}
if (component_mapping == null) {
- throw new VersionsException("Element for component not found
during second pass!");
+ throw new AuditException("Element for component not found during
second pass!");
}
} else {
*/
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 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -55,7 +55,7 @@
import org.hibernate.envers.entities.mapper.relation.lazy.proxy.SetProxy;
import org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedMapProxy;
import org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedSetProxy;
-import
org.hibernate.envers.entities.mapper.relation.query.OneVersionsEntityQueryGenerator;
+import org.hibernate.envers.entities.mapper.relation.query.OneAuditEntityQueryGenerator;
import org.hibernate.envers.entities.mapper.relation.query.RelationQueryGenerator;
import org.hibernate.envers.tools.StringTools;
import org.hibernate.envers.tools.Tools;
@@ -124,7 +124,7 @@
referencingEntityConfiguration =
mainGenerator.getEntitiesConfigurations().get(referencingEntityName);
if (referencingEntityConfiguration == null) {
- throw new MappingException("Unable to read versioning configuration for
" + referencingEntityName + "!");
+ throw new MappingException("Unable to read auditing configuration for
" + referencingEntityName + "!");
}
referencedEntityName = getReferencedEntityName(propertyValue.getElement());
@@ -182,7 +182,7 @@
MiddleComponentData indexComponentData = addIndex(null, null);
// Generating the query generator - it should read directly from the related
entity.
- RelationQueryGenerator queryGenerator = new
OneVersionsEntityQueryGenerator(mainGenerator.getGlobalCfg(),
+ RelationQueryGenerator queryGenerator = new
OneAuditEntityQueryGenerator(mainGenerator.getGlobalCfg(),
mainGenerator.getVerEntCfg(), referencingIdData, referencedEntityName,
referencedIdMapping.getIdMapper());
@@ -233,22 +233,22 @@
@SuppressWarnings({"unchecked"})
private void addWithMiddleTable() {
// Generating the name of the middle table
- String versionsMiddleTableName;
- String versionsMiddleEntityName;
+ String auditMiddleTableName;
+ String auditMiddleEntityName;
if (!StringTools.isEmpty(persistentPropertyAuditingData.getJoinTable().name()))
{
- versionsMiddleTableName =
persistentPropertyAuditingData.getJoinTable().name();
- versionsMiddleEntityName =
persistentPropertyAuditingData.getJoinTable().name();
+ auditMiddleTableName = persistentPropertyAuditingData.getJoinTable().name();
+ auditMiddleEntityName =
persistentPropertyAuditingData.getJoinTable().name();
} else {
String middleTableName = getMiddleTableName(propertyValue,
referencingEntityName);
- versionsMiddleTableName =
mainGenerator.getVerEntCfg().getVersionsTableName(null, middleTableName);
- versionsMiddleEntityName =
mainGenerator.getVerEntCfg().getVersionsEntityName(middleTableName);
+ auditMiddleTableName = mainGenerator.getVerEntCfg().getAuditTableName(null,
middleTableName);
+ auditMiddleEntityName =
mainGenerator.getVerEntCfg().getAuditEntityName(middleTableName);
}
// Generating the XML mapping for the middle entity, only if the relation
isn't inverse.
// If the relation is inverse, will be later checked by comparing middleEntityXml
with null.
Element middleEntityXml;
if (!propertyValue.isInverse()) {
- middleEntityXml = createMiddleEntityXml(versionsMiddleTableName,
versionsMiddleEntityName);
+ middleEntityXml = createMiddleEntityXml(auditMiddleTableName,
auditMiddleEntityName);
} else {
middleEntityXml = null;
}
@@ -287,7 +287,7 @@
// references some entities (either from the element or index). At the end, this
will be used to build
// a query generator to read the raw data collection from the middle table.
QueryGeneratorBuilder queryGeneratorBuilder = new
QueryGeneratorBuilder(mainGenerator.getGlobalCfg(),
- mainGenerator.getVerEntCfg(), referencingIdData,
versionsMiddleEntityName);
+ mainGenerator.getVerEntCfg(), referencingIdData, auditMiddleEntityName);
// Adding the XML mapping for the referencing entity, if the relation isn't
inverse.
if (middleEntityXml != null) {
@@ -316,7 +316,7 @@
// Creating common data
CommonCollectionMapperData commonCollectionMapperData = new
CommonCollectionMapperData(
- mainGenerator.getVerEntCfg(), versionsMiddleEntityName,
+ mainGenerator.getVerEntCfg(), auditMiddleEntityName,
persistentPropertyAuditingData.getPropertyData(),
referencingIdData, queryGenerator);
@@ -461,14 +461,14 @@
}
}
- private Element createMiddleEntityXml(String versionsMiddleTableName, String
versionsMiddleEntityName) {
+ private Element createMiddleEntityXml(String auditMiddleTableName, String
auditMiddleEntityName) {
String schema =
StringTools.isEmpty(persistentPropertyAuditingData.getJoinTable().schema()) ?
propertyValue.getCollectionTable().getSchema() :
persistentPropertyAuditingData.getJoinTable().schema();
String catalog =
StringTools.isEmpty(persistentPropertyAuditingData.getJoinTable().catalog()) ?
propertyValue.getCollectionTable().getCatalog() :
persistentPropertyAuditingData.getJoinTable().catalog();
Element middleEntityXml =
MetadataTools.createEntity(xmlMappingData.newAdditionalMapping(),
- versionsMiddleEntityName, versionsMiddleTableName, schema, catalog,
null);
+ auditMiddleEntityName, auditMiddleTableName, schema, catalog, null);
Element middleEntityXmlId =
middleEntityXml.addElement("composite-id");
middleEntityXmlId.addAttribute("name",
mainGenerator.getVerEntCfg().getOriginalIdPropName());
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -50,8 +50,8 @@
public final class IdMetadataGenerator {
private final AuditMetadataGenerator mainGenerator;
- IdMetadataGenerator(AuditMetadataGenerator versionsMetadataGenerator) {
- mainGenerator = versionsMetadataGenerator;
+ IdMetadataGenerator(AuditMetadataGenerator auditMetadataGenerator) {
+ mainGenerator = auditMetadataGenerator;
}
@SuppressWarnings({"unchecked"})
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/QueryGeneratorBuilder.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/QueryGeneratorBuilder.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/QueryGeneratorBuilder.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -44,15 +44,15 @@
private final GlobalConfiguration globalCfg;
private final AuditEntitiesConfiguration verEntCfg;
private final MiddleIdData referencingIdData;
- private final String versionsMiddleEntityName;
+ private final String auditMiddleEntityName;
private final List<MiddleIdData> idDatas;
QueryGeneratorBuilder(GlobalConfiguration globalCfg, AuditEntitiesConfiguration
verEntCfg,
- MiddleIdData referencingIdData, String
versionsMiddleEntityName) {
+ MiddleIdData referencingIdData, String auditMiddleEntityName)
{
this.globalCfg = globalCfg;
this.verEntCfg = verEntCfg;
this.referencingIdData = referencingIdData;
- this.versionsMiddleEntityName = versionsMiddleEntityName;
+ this.auditMiddleEntityName = auditMiddleEntityName;
idDatas = new ArrayList<MiddleIdData>();
}
@@ -63,13 +63,13 @@
RelationQueryGenerator build(MiddleComponentData... componentDatas) {
if (idDatas.size() == 0) {
- return new OneEntityQueryGenerator(verEntCfg, versionsMiddleEntityName,
referencingIdData,
+ return new OneEntityQueryGenerator(verEntCfg, auditMiddleEntityName,
referencingIdData,
componentDatas);
} else if (idDatas.size() == 1) {
- return new TwoEntityQueryGenerator(globalCfg, verEntCfg,
versionsMiddleEntityName, referencingIdData,
+ return new TwoEntityQueryGenerator(globalCfg, verEntCfg,
auditMiddleEntityName, referencingIdData,
idDatas.get(0), componentDatas);
} else if (idDatas.size() == 2) {
- return new ThreeEntityQueryGenerator(globalCfg, verEntCfg,
versionsMiddleEntityName, referencingIdData,
+ return new ThreeEntityQueryGenerator(globalCfg, verEntCfg,
auditMiddleEntityName, referencingIdData,
idDatas.get(0), idDatas.get(1), componentDatas);
} else {
throw new IllegalStateException("Illegal number of related
entities.");
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/ToOneRelationMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/ToOneRelationMetadataGenerator.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/ToOneRelationMetadataGenerator.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -44,8 +44,8 @@
public final class ToOneRelationMetadataGenerator {
private final AuditMetadataGenerator mainGenerator;
- ToOneRelationMetadataGenerator(AuditMetadataGenerator versionsMetadataGenerator) {
- mainGenerator = versionsMetadataGenerator;
+ ToOneRelationMetadataGenerator(AuditMetadataGenerator auditMetadataGenerator) {
+ mainGenerator = auditMetadataGenerator;
}
@SuppressWarnings({"unchecked"})
@@ -55,7 +55,7 @@
EntityConfiguration configuration =
mainGenerator.getEntitiesConfigurations().get(referencedEntityName);
if (configuration == null) {
- throw new MappingException("A versioned relation to a non-versioned
entity " + referencedEntityName + "!");
+ throw new MappingException("An audited relation to a non-audited entity
" + referencedEntityName + "!");
}
IdMappingData idMapping = configuration.getIdMappingData();
@@ -91,13 +91,13 @@
EntityConfiguration configuration =
mainGenerator.getEntitiesConfigurations().get(entityName);
if (configuration == null) {
- throw new MappingException("A versioned relation to a non-versioned
entity " + entityName + "!");
+ throw new MappingException("An audited relation to a non-audited entity
" + entityName + "!");
}
IdMappingData ownedIdMapping = configuration.getIdMappingData();
if (ownedIdMapping == null) {
- throw new MappingException("A versioned relation to a non-versioned
entity " + entityName + "!");
+ throw new MappingException("An audited relation to a non-audited entity
" + entityName + "!");
}
String lastPropertyPrefix = owningReferencePropertyName + "_";
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MiddleIdData.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MiddleIdData.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MiddleIdData.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -55,7 +55,7 @@
this.originalMapper = mappingData.getIdMapper();
this.prefixedMapper = mappingData.getIdMapper().prefixMappedProperties(prefix);
this.entityName = entityName;
- this.versionsEntityName = verEntCfg.getVersionsEntityName(entityName);
+ this.versionsEntityName = verEntCfg.getAuditEntityName(entityName);
}
public IdMapper getOriginalMapper() {
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneVersionsEntityQueryGenerator.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,110 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.entities.mapper.relation.query;
+
+import java.util.Collections;
+
+import org.hibernate.envers.RevisionType;
+import org.hibernate.envers.configuration.GlobalConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
+import org.hibernate.envers.entities.mapper.id.IdMapper;
+import org.hibernate.envers.entities.mapper.id.QueryParameterData;
+import org.hibernate.envers.entities.mapper.relation.MiddleIdData;
+import org.hibernate.envers.reader.AuditReaderImplementor;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+import org.hibernate.Query;
+
+/**
+ * Selects data from an audit entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public final class OneAuditEntityQueryGenerator implements RelationQueryGenerator {
+ private final String queryString;
+ private final MiddleIdData referencingIdData;
+
+ public OneAuditEntityQueryGenerator(GlobalConfiguration globalCfg,
AuditEntitiesConfiguration verEntCfg,
+ MiddleIdData referencingIdData, String
referencedEntityName,
+ IdMapper referencedIdMapper) {
+ this.referencingIdData = referencingIdData;
+
+ /*
+ * The query that we need to create:
+ * SELECT new list(e) FROM versionsReferencedEntity e
+ * WHERE
+ * (only entities referenced by the association; id_ref_ing = id of the
referencing entity)
+ * e.id_ref_ing = :id_ref_ing AND
+ * (selecting e entities at revision :revision)
+ * e.revision = (SELECT max(e2.revision) FROM versionsReferencedEntity e2
+ * WHERE e2.revision <= :revision AND e2.id = e.id) AND
+ * (only non-deleted entities)
+ * e.revision_type != DEL
+ */
+ String revisionPropertyPath = verEntCfg.getRevisionPropPath();
+ String originalIdPropertyName = verEntCfg.getOriginalIdPropName();
+
+ String versionsReferencedEntityName =
verEntCfg.getAuditEntityName(referencedEntityName);
+
+ // SELECT new list(e) FROM versionsEntity e
+ QueryBuilder qb = new QueryBuilder(versionsReferencedEntityName, "e");
+ qb.addProjection("new list", "e", false, false);
+ // WHERE
+ Parameters rootParameters = qb.getRootParameters();
+ // e.id_ref_ed = :id_ref_ed
+ referencingIdData.getPrefixedMapper().addNamedIdEqualsToQuery(rootParameters,
null, true);
+
+ // SELECT max(e.revision) FROM versionsReferencedEntity e2
+ QueryBuilder maxERevQb = qb.newSubQueryBuilder(versionsReferencedEntityName,
"e2");
+ maxERevQb.addProjection("max", revisionPropertyPath, false);
+ // WHERE
+ Parameters maxERevQbParameters = maxERevQb.getRootParameters();
+ // e2.revision <= :revision
+ maxERevQbParameters.addWhereWithNamedParam(revisionPropertyPath,
"<=", "revision");
+ // e2.id = e.id
+ referencedIdMapper.addIdsEqualToQuery(maxERevQbParameters,
+ "e." + originalIdPropertyName, "e2." +
originalIdPropertyName);
+
+ // e.revision = (SELECT max(...) ...)
+ rootParameters.addWhere(revisionPropertyPath, false,
globalCfg.getCorrelatedSubqueryOperator(), maxERevQb);
+
+ // e.revision_type != DEL
+ rootParameters.addWhereWithNamedParam(verEntCfg.getRevisionTypePropName(), false,
"!=", "delrevisiontype");
+
+ StringBuilder sb = new StringBuilder();
+ qb.build(sb, Collections.<String, Object>emptyMap());
+ queryString = sb.toString();
+ }
+
+ public Query getQuery(AuditReaderImplementor versionsReader, Object primaryKey,
Number revision) {
+ Query query = versionsReader.getSession().createQuery(queryString);
+ query.setParameter("revision", revision);
+ query.setParameter("delrevisiontype", RevisionType.DEL);
+ for (QueryParameterData paramData:
referencingIdData.getPrefixedMapper().mapToQueryParametersFromId(primaryKey)) {
+ paramData.setParameterValue(query);
+ }
+
+ return query;
+ }
+}
\ No newline at end of file
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -43,175 +43,175 @@
* Apply an "equal" constraint to the identifier property.
*/
public static AuditCriterion idEq(Object value) {
- return new IdentifierEqVersionsExpression(value);
+ return new IdentifierEqAuditExpression(value);
}
/**
* Apply an "equal" constraint to the named property
*/
public static AuditCriterion eq(String propertyName, Object value) {
- return new SimpleVersionsExpression(propertyName, value, "=");
+ return new SimpleAuditExpression(propertyName, value, "=");
}
/**
* Apply a "not equal" constraint to the named property
*/
public static AuditCriterion ne(String propertyName, Object value) {
- return new SimpleVersionsExpression(propertyName, value, "<>");
+ return new SimpleAuditExpression(propertyName, value, "<>");
}
/**
* Apply an "equal" constraint on an id of a related entity
*/
public static AuditCriterion relatedIdEq(String propertyName, Object id) {
- return new RelatedVersionsExpression(propertyName, id, true);
+ return new RelatedAuditExpression(propertyName, id, true);
}
/**
* Apply a "not equal" constraint to the named property
*/
public static AuditCriterion relatedIdNe(String propertyName, Object id) {
- return new RelatedVersionsExpression(propertyName, id, false);
+ return new RelatedAuditExpression(propertyName, id, false);
}
/**
* Apply a "like" constraint to the named property
*/
public static AuditCriterion like(String propertyName, Object value) {
- return new SimpleVersionsExpression(propertyName, value, " like ");
+ return new SimpleAuditExpression(propertyName, value, " like ");
}
/**
* Apply a "like" constraint to the named property
*/
public static AuditCriterion like(String propertyName, String value, MatchMode
matchMode) {
- return new SimpleVersionsExpression(propertyName, matchMode.toMatchString(value),
" like " );
+ return new SimpleAuditExpression(propertyName, matchMode.toMatchString(value), "
like " );
}
/**
* Apply a "greater than" constraint to the named property
*/
public static AuditCriterion gt(String propertyName, Object value) {
- return new SimpleVersionsExpression(propertyName, value, ">");
+ return new SimpleAuditExpression(propertyName, value, ">");
}
/**
* Apply a "less than" constraint to the named property
*/
public static AuditCriterion lt(String propertyName, Object value) {
- return new SimpleVersionsExpression(propertyName, value, "<");
+ return new SimpleAuditExpression(propertyName, value, "<");
}
/**
* Apply a "less than or equal" constraint to the named property
*/
public static AuditCriterion le(String propertyName, Object value) {
- return new SimpleVersionsExpression(propertyName, value, "<=");
+ return new SimpleAuditExpression(propertyName, value, "<=");
}
/**
* Apply a "greater than or equal" constraint to the named property
*/
public static AuditCriterion ge(String propertyName, Object value) {
- return new SimpleVersionsExpression(propertyName, value, ">=");
+ return new SimpleAuditExpression(propertyName, value, ">=");
}
/**
* Apply a "between" constraint to the named property
*/
public static AuditCriterion between(String propertyName, Object lo, Object hi) {
- return new BetweenVersionsExpression(propertyName, lo, hi);
+ return new BetweenAuditExpression(propertyName, lo, hi);
}
/**
* Apply an "in" constraint to the named property
*/
public static AuditCriterion in(String propertyName, Object[] values) {
- return new InVersionsExpression(propertyName, values);
+ return new InAuditExpression(propertyName, values);
}
/**
* Apply an "in" constraint to the named property
*/
public static AuditCriterion in(String propertyName, Collection values) {
- return new InVersionsExpression(propertyName, values.toArray());
+ return new InAuditExpression(propertyName, values.toArray());
}
/**
* Apply an "is null" constraint to the named property
*/
public static AuditCriterion isNull(String propertyName) {
- return new NullVersionsExpression(propertyName);
+ return new NullAuditExpression(propertyName);
}
/**
* Apply an "equal" constraint to two properties
*/
public static AuditCriterion eqProperty(String propertyName, String otherPropertyName)
{
- return new PropertyVersionsExpression(propertyName, otherPropertyName, "=");
+ return new PropertyAuditExpression(propertyName, otherPropertyName, "=");
}
/**
* Apply a "not equal" constraint to two properties
*/
public static AuditCriterion neProperty(String propertyName, String otherPropertyName)
{
- return new PropertyVersionsExpression(propertyName, otherPropertyName,
"<>");
+ return new PropertyAuditExpression(propertyName, otherPropertyName,
"<>");
}
/**
* Apply a "less than" constraint to two properties
*/
public static AuditCriterion ltProperty(String propertyName, String otherPropertyName)
{
- return new PropertyVersionsExpression(propertyName, otherPropertyName,
"<");
+ return new PropertyAuditExpression(propertyName, otherPropertyName, "<");
}
/**
* Apply a "less than or equal" constraint to two properties
*/
public static AuditCriterion leProperty(String propertyName, String otherPropertyName)
{
- return new PropertyVersionsExpression(propertyName, otherPropertyName,
"<=");
+ return new PropertyAuditExpression(propertyName, otherPropertyName,
"<=");
}
/**
* Apply a "greater than" constraint to two properties
*/
public static AuditCriterion gtProperty(String propertyName, String otherPropertyName)
{
- return new PropertyVersionsExpression(propertyName, otherPropertyName,
">");
+ return new PropertyAuditExpression(propertyName, otherPropertyName, ">");
}
/**
* Apply a "greater than or equal" constraint to two properties
*/
public static AuditCriterion geProperty(String propertyName, String otherPropertyName)
{
- return new PropertyVersionsExpression(propertyName, otherPropertyName,
">=");
+ return new PropertyAuditExpression(propertyName, otherPropertyName,
">=");
}
/**
* Apply an "is not null" constraint to the named property
*/
public static AuditCriterion isNotNull(String propertyName) {
- return new NotNullVersionsExpression(propertyName);
+ return new NotNullAuditExpression(propertyName);
}
/**
* Return the conjuction of two expressions
*/
public static AuditCriterion and(AuditCriterion lhs, AuditCriterion rhs) {
- return new LogicalVersionsExpression(lhs, rhs, "and");
+ return new LogicalAuditExpression(lhs, rhs, "and");
}
/**
* Return the disjuction of two expressions
*/
public static AuditCriterion or(AuditCriterion lhs, AuditCriterion rhs) {
- return new LogicalVersionsExpression(lhs, rhs, "or");
+ return new LogicalAuditExpression(lhs, rhs, "or");
}
/**
* Return the negation of an expression
*/
public static AuditCriterion not(AuditCriterion expression) {
- return new NotVersionsExpression(expression);
+ return new NotAuditExpression(expression);
}
/**
@@ -231,16 +231,16 @@
/**
* Apply a "maximalize property" constraint.
*/
- public static AggregatedFieldVersionsExpression maximizeProperty(String propertyName)
{
- return new AggregatedFieldVersionsExpression(propertyName,
- AggregatedFieldVersionsExpression.AggregatedMode.MAX);
+ public static AggregatedFieldAuditExpression maximizeProperty(String propertyName) {
+ return new AggregatedFieldAuditExpression(propertyName,
+ AggregatedFieldAuditExpression.AggregatedMode.MAX);
}
/**
* Apply a "minimize property" constraint.
*/
- public static AggregatedFieldVersionsExpression minimizeProperty(String propertyName)
{
- return new AggregatedFieldVersionsExpression(propertyName,
- AggregatedFieldVersionsExpression.AggregatedMode.MIN);
+ public static AggregatedFieldAuditExpression minimizeProperty(String propertyName) {
+ return new AggregatedFieldAuditExpression(propertyName,
+ AggregatedFieldAuditExpression.AggregatedMode.MIN);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -24,11 +24,11 @@
package org.hibernate.envers.query;
import org.hibernate.envers.configuration.AuditConfiguration;
-import org.hibernate.envers.query.criteria.RevisionVersionsExpression;
+import org.hibernate.envers.query.criteria.RevisionAuditExpression;
import org.hibernate.envers.query.criteria.AuditCriterion;
-import org.hibernate.envers.query.order.RevisionVersionsOrder;
+import org.hibernate.envers.query.order.RevisionAuditOrder;
import org.hibernate.envers.query.order.AuditOrder;
-import org.hibernate.envers.query.projection.RevisionVersionsProjection;
+import org.hibernate.envers.query.projection.RevisionAuditProjection;
import org.hibernate.envers.query.projection.AuditProjection;
import org.hibernate.envers.tools.Triple;
@@ -43,77 +43,77 @@
* Apply a "greater than" constraint on the revision number
*/
public static AuditCriterion gt(Integer revision) {
- return new RevisionVersionsExpression(revision, ">");
+ return new RevisionAuditExpression(revision, ">");
}
/**
* Apply a "greater than or equal" constraint on the revision number
*/
public static AuditCriterion ge(Integer revision) {
- return new RevisionVersionsExpression(revision, ">=");
+ return new RevisionAuditExpression(revision, ">=");
}
/**
* Apply a "less than" constraint on the revision number
*/
public static AuditCriterion lt(Integer revision) {
- return new RevisionVersionsExpression(revision, "<");
+ return new RevisionAuditExpression(revision, "<");
}
/**
* Apply a "less than or equal" constraint on the revision number
*/
public static AuditCriterion le(Integer revision) {
- return new RevisionVersionsExpression(revision, "<=");
+ return new RevisionAuditExpression(revision, "<=");
}
/**
* Sort the results by revision in ascending order
*/
public static AuditOrder asc() {
- return new RevisionVersionsOrder(true);
+ return new RevisionAuditOrder(true);
}
/**
* Sort the results by revision in descending order
*/
public static AuditOrder desc() {
- return new RevisionVersionsOrder(false);
+ return new RevisionAuditOrder(false);
}
/**
* Select the maximum revision
*/
public static AuditProjection max() {
- return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.MAX);
+ return new RevisionAuditProjection(RevisionAuditProjection.ProjectionType.MAX);
}
/**
* Select the minimum revision
*/
public static AuditProjection min() {
- return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.MIN);
+ return new RevisionAuditProjection(RevisionAuditProjection.ProjectionType.MIN);
}
/**
* Count revisions
*/
public static AuditProjection count() {
- return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.COUNT);
+ return new
RevisionAuditProjection(RevisionAuditProjection.ProjectionType.COUNT);
}
/**
* Count distinct revisions
*/
public static AuditProjection countDistinct() {
- return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.COUNT_DISTINCT);
+ return new
RevisionAuditProjection(RevisionAuditProjection.ProjectionType.COUNT_DISTINCT);
}
/**
* Distinct revisions
*/
public static AuditProjection distinct() {
- return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.DISTINCT);
+ return new
RevisionAuditProjection(RevisionAuditProjection.ProjectionType.DISTINCT);
}
/**
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,82 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AggregatedFieldAuditExpression implements AuditCriterion,
ExtendableCriterion {
+ public static enum AggregatedMode {
+ MAX,
+ MIN
+ }
+
+ private String propertyName;
+ private AggregatedMode mode;
+ private List<AuditCriterion> criterions;
+
+ public AggregatedFieldAuditExpression(String propertyName, AggregatedMode mode) {
+ this.propertyName = propertyName;
+ this.mode = mode;
+ criterions = new ArrayList<AuditCriterion>();
+ }
+
+ public AggregatedFieldAuditExpression add(AuditCriterion criterion) {
+ criterions.add(criterion);
+ return this;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
+
+ // This will be the aggregated query, containing all the specified conditions
+ QueryBuilder subQb = qb.newSubQueryBuilder();
+
+ // Adding all specified conditions both to the main query, as well as to the
+ // aggregated one.
+ for (AuditCriterion versionsCriteria : criterions) {
+ versionsCriteria.addToQuery(verCfg, entityName, qb, parameters);
+ versionsCriteria.addToQuery(verCfg, entityName, subQb,
subQb.getRootParameters());
+ }
+
+ // Setting the desired projection of the aggregated query
+ switch (mode) {
+ case MIN:
+ subQb.addProjection("min", propertyName, false);
+ break;
+ case MAX:
+ subQb.addProjection("max", propertyName, false);
+ }
+
+ // Adding the constrain on the result of the aggregated criteria
+ parameters.addWhere(propertyName, "=", subQb);
+ }
+}
\ No newline at end of file
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BetweenAuditExpression implements AuditCriterion {
+ private String propertyName;
+ private Object lo;
+ private Object hi;
+
+ public BetweenAuditExpression(String propertyName, Object lo, Object hi) {
+ this.propertyName = propertyName;
+ this.lo = lo;
+ this.hi = hi;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
+ parameters.addWhereWithParam(propertyName, ">=", lo);
+ parameters.addWhereWithParam(propertyName, "<=", hi);
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class IdentifierEqAuditExpression implements AuditCriterion {
+ private Object id;
+
+ public IdentifierEqAuditExpression(Object id) {
+ this.id = id;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ verCfg.getEntCfg().get(entityName).getIdMapper()
+ .addIdEqualsToQuery(parameters, id,
verCfg.getAuditEntCfg().getOriginalIdPropName(), true);
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class InAuditExpression implements AuditCriterion {
+ private String propertyName;
+ private Object[] values;
+
+ public InAuditExpression(String propertyName, Object[] values) {
+ this.propertyName = propertyName;
+ this.values = values;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
+ parameters.addWhereWithParams(propertyName, "in (", values,
")");
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class LogicalAuditExpression implements AuditCriterion {
+ private AuditCriterion lhs;
+ private AuditCriterion rhs;
+ private String op;
+
+ public LogicalAuditExpression(AuditCriterion lhs, AuditCriterion rhs, String op) {
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.op = op;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ Parameters opParameters = parameters.addSubParameters(op);
+
+ lhs.addToQuery(verCfg, entityName, qb,
opParameters.addSubParameters("and"));
+ rhs.addToQuery(verCfg, entityName, qb,
opParameters.addSubParameters("and"));
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class NotAuditExpression implements AuditCriterion {
+ private AuditCriterion criterion;
+
+ public NotAuditExpression(AuditCriterion criterion) {
+ this.criterion = criterion;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ criterion.addToQuery(verCfg, entityName, qb, parameters.addNegatedParameters());
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.entities.RelationDescription;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class NotNullAuditExpression implements AuditCriterion {
+ private String propertyName;
+
+ public NotNullAuditExpression(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg,
entityName, propertyName);
+
+ if (relatedEntity == null) {
+ parameters.addWhereWithParam(propertyName, "<>", null);
+ } else {
+ relatedEntity.getIdMapper().addIdEqualsToQuery(parameters, null,
propertyName, false);
+ }
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.entities.RelationDescription;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class NullAuditExpression implements AuditCriterion {
+ private String propertyName;
+
+ public NullAuditExpression(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg,
entityName, propertyName);
+
+ if (relatedEntity == null) {
+ parameters.addWhereWithParam(propertyName, "=", null);
+ } else {
+ relatedEntity.getIdMapper().addIdEqualsToQuery(parameters, null,
propertyName, true);
+ }
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class PropertyAuditExpression implements AuditCriterion {
+ private String propertyName;
+ private String otherPropertyName;
+ private String op;
+
+ public PropertyAuditExpression(String propertyName, String otherPropertyName, String
op) {
+ this.propertyName = propertyName;
+ this.otherPropertyName = otherPropertyName;
+ this.op = op;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
+ CriteriaTools.checkPropertyNotARelation(verCfg, entityName, otherPropertyName);
+ parameters.addWhere(propertyName, op, otherPropertyName);
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.entities.RelationDescription;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RelatedAuditExpression implements AuditCriterion {
+ private String propertyName;
+ private Object id;
+ private boolean equals;
+
+ public RelatedAuditExpression(String propertyName, Object id, boolean equals) {
+ this.propertyName = propertyName;
+ this.id = id;
+ this.equals = equals;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg,
entityName, propertyName);
+
+ if (relatedEntity == null) {
+ throw new AuditException("This criterion can only be used on a property
that is " +
+ "a relation to another property.");
+ } else {
+ relatedEntity.getIdMapper().addIdEqualsToQuery(parameters, id, propertyName,
equals);
+ }
+ }
+}
\ No newline at end of file
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionAuditExpression implements AuditCriterion {
+ private Object value;
+ private String op;
+
+ public RevisionAuditExpression(Object value, String op) {
+ this.value = value;
+ this.op = op;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ parameters.addWhereWithParam(verCfg.getAuditEntCfg().getRevisionPropPath(), op,
value);
+ }
+}
\ No newline at end of file
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleVersionsExpression.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,62 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.criteria;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.entities.RelationDescription;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class SimpleAuditExpression implements AuditCriterion {
+ private String propertyName;
+ private Object value;
+ private String op;
+
+ public SimpleAuditExpression(String propertyName, Object value, String op) {
+ this.propertyName = propertyName;
+ this.value = value;
+ this.op = op;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg,
entityName, propertyName);
+
+ if (relatedEntity == null) {
+ parameters.addWhereWithParam(propertyName, op, value);
+ } else {
+ if (!"=".equals(op) && !"<>".equals(op)) {
+ throw new AuditException("This type of operation: " + op +
" (" + entityName + "." + propertyName +
+ ") isn't supported and can't be used in
queries.");
+ }
+
+ Object id = relatedEntity.getIdMapper().mapToIdFromEntity(value);
+
+ relatedEntity.getIdMapper().addIdEqualsToQuery(parameters, id, propertyName,
"=".equals(op));
+ }
+ }
+}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -73,7 +73,7 @@
entityInstantiator = new EntityInstantiator(verCfg, versionsReader);
entityName = cls.getName();
- versionsEntityName = verCfg.getAuditEntCfg().getVersionsEntityName(entityName);
+ versionsEntityName = verCfg.getAuditEntCfg().getAuditEntityName(entityName);
qb = new QueryBuilder(versionsEntityName, "e");
}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionVersionsOrder.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.order;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.Pair;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionAuditOrder implements AuditOrder {
+ private final boolean asc;
+
+ public RevisionAuditOrder(boolean asc) {
+ this.asc = asc;
+ }
+
+ public Pair<String, Boolean> getData(AuditConfiguration verCfg) {
+ String revisionPropPath = verCfg.getAuditEntCfg().getRevisionPropPath();
+ return Pair.make(revisionPropPath, asc);
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java
(from rev 15513,
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionVersionsProjection.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -0,0 +1,60 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.query.projection;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.Triple;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionAuditProjection implements AuditProjection {
+ public static enum ProjectionType {
+ MAX,
+ MIN,
+ COUNT,
+ COUNT_DISTINCT,
+ DISTINCT
+ }
+
+ private final ProjectionType type;
+
+ public RevisionAuditProjection(ProjectionType type) {
+ this.type = type;
+ }
+
+ public Triple<String, String, Boolean> getData(AuditConfiguration verCfg) {
+ String revisionPropPath = verCfg.getAuditEntCfg().getRevisionPropPath();
+
+ switch (type) {
+ case MAX: return Triple.make("max", revisionPropPath, false);
+ case MIN: return Triple.make("min", revisionPropPath, false);
+ case COUNT: return Triple.make("count", revisionPropPath, false);
+ case COUNT_DISTINCT: return Triple.make("count", revisionPropPath,
true);
+ case DISTINCT: return Triple.make(null, revisionPropPath, true);
+ }
+
+ throw new IllegalArgumentException("Unknown type " + type +
".");
+ }
+}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -79,7 +79,7 @@
public void undo(Session session) {
if (isPerformed()) {
-
session.delete(verCfg.getAuditEntCfg().getVersionsEntityName(getEntityName()),
performedData);
+ session.delete(verCfg.getAuditEntCfg().getAuditEntityName(getEntityName()),
performedData);
session.flush();
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AddWorkUnit.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AddWorkUnit.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AddWorkUnit.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -58,7 +58,7 @@
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper().map(data,
propertyNames, state, null);
- session.save(verCfg.getAuditEntCfg().getVersionsEntityName(getEntityName()),
data);
+ session.save(verCfg.getAuditEntCfg().getAuditEntityName(getEntityName()), data);
setPerformed(data);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/CollectionChangeWorkUnit.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/CollectionChangeWorkUnit.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/CollectionChangeWorkUnit.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -54,7 +54,7 @@
verCfg.getEntCfg().get(getEntityName()).getPropertyMapper().mapToMapFromEntity(data,
entity, null);
- session.save(verCfg.getAuditEntCfg().getVersionsEntityName(getEntityName()),
data);
+ session.save(verCfg.getAuditEntCfg().getAuditEntityName(getEntityName()), data);
setPerformed(data);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/DelWorkUnit.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/DelWorkUnit.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/DelWorkUnit.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -48,7 +48,7 @@
Map<String, Object> data = new HashMap<String, Object>();
fillDataWithId(data, revisionData, RevisionType.DEL);
- session.save(verCfg.getAuditEntCfg().getVersionsEntityName(getEntityName()),
data);
+ session.save(verCfg.getAuditEntCfg().getAuditEntityName(getEntityName()), data);
setPerformed(data);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/ModWorkUnit.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/ModWorkUnit.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/ModWorkUnit.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -56,7 +56,7 @@
public void perform(Session session, Object revisionData) {
fillDataWithId(data, revisionData, RevisionType.MOD);
- session.save(verCfg.getAuditEntCfg().getVersionsEntityName(getEntityName()),
data);
+ session.save(verCfg.getAuditEntCfg().getAuditEntityName(getEntityName()), data);
setPerformed(data);
}
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/SecondaryNamingTestEntity.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/SecondaryNamingTestEntity.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/SecondaryNamingTestEntity.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -37,7 +37,7 @@
*/
@Entity
@SecondaryTable(name = "secondary")
-@SecondaryAuditTable(secondaryTableName = "secondary",
secondaryVersionsTableName = "sec_versions")
+@SecondaryAuditTable(secondaryTableName = "secondary", secondaryAuditTableName
= "sec_versions")
@Audited
public class SecondaryNamingTestEntity {
@Id
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryEmbIdTestEntity.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryEmbIdTestEntity.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryEmbIdTestEntity.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -37,7 +37,7 @@
*/
@Entity
@SecondaryTable(name = "secondary")
-@SecondaryAuditTable(secondaryTableName = "secondary",
secondaryVersionsTableName = "sec_embid_versions")
+@SecondaryAuditTable(secondaryTableName = "secondary", secondaryAuditTableName
= "sec_embid_versions")
@Audited
public class SecondaryEmbIdTestEntity {
@Id
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryMulIdTestEntity.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryMulIdTestEntity.java 2008-11-05
08:59:14 UTC (rev 15516)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/secondary/ids/SecondaryMulIdTestEntity.java 2008-11-05
09:13:05 UTC (rev 15517)
@@ -38,7 +38,7 @@
*/
@Entity
@SecondaryTable(name = "secondary")
-@SecondaryAuditTable(secondaryTableName = "secondary",
secondaryVersionsTableName = "sec_mulid_versions")
+@SecondaryAuditTable(secondaryTableName = "secondary", secondaryAuditTableName
= "sec_mulid_versions")
@Audited
@IdClass(MulId.class)
public class SecondaryMulIdTestEntity {