Author: adamw
Date: 2008-10-31 07:53:38 -0400 (Fri, 31 Oct 2008)
New Revision: 15460
Added:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQuery.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQueryCreator.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditConjunction.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditCriterion.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditDisjunction.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/AuditOrder.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/AuditProjection.java
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSyncManager.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/AuditWorkUnit.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/ant/AnnotationConfigurationTaskWithEnvers.java
core/trunk/envers/src/main/java/org/hibernate/envers/ant/ConfigurationTaskWithEnvers.java
core/trunk/envers/src/main/java/org/hibernate/envers/ant/JPAConfigurationTaskWithEnvers.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.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/EntityInstantiator.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MapPropertyMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MultiPropertyMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/PropertyMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SinglePropertyMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SubclassPropertyMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/AbstractCompositeIdMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/EmbeddedIdMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/MultipleIdMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/SingleIdMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/AbstractCollectionMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/BasicCollectionMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/CommonCollectionMapperData.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ListCollectionMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MapCollectionMapper.java
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/OneToOneNotOwningMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ToOneIdMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleMapKeyIdComponentMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleSimpleComponentMapper.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/ToOneDelegateSessionImplementor.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/AbstractCollectionInitializor.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ArrayCollectionInitializor.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java
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/RelationQueryGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/ThreeEntityQueryGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityQueryGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/event/VersionsEventListener.java
core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotVersionedException.java
core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionTypeProperty.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/CriteriaTools.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/ExtendableCriterion.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleVersionsExpression.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractVersionsQuery.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/EntitiesAtRevisionQuery.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/RevisionsOfEntityQuery.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionVersionsOrder.java
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionVersionsProjection.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/main/java/org/hibernate/envers/synchronization/work/PersistentCollectionChangeWorkUnit.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLog.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLogManager.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/ReflectionTools.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YClass.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YMethodsAndClasses.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YProperty.java
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YReflectionManager.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/CustomRevEntityQuery.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/DeletedEntities.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/MaximalizePropertyQuery.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/RevisionConstraintQuery.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/SimpleQuery.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/EmbIdOneToManyQuery.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/MulIdOneToManyQuery.java
Log:
HHH-3570: renaming versioned to audited
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/AuditReader.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/AuditReader.java 2008-10-31
11:42:38 UTC (rev 15459)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/AuditReader.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import org.hibernate.envers.exception.NotVersionedException;
import org.hibernate.envers.exception.RevisionDoesNotExistException;
-import org.hibernate.envers.query.VersionsQueryCreator;
+import org.hibernate.envers.query.AuditQueryCreator;
/**
* @author Adam Warski (adam at warski dot org)
@@ -106,5 +106,5 @@
* created and later executed. Shouldn't be used after the associated Session or
EntityManager
* is closed.
*/
- VersionsQueryCreator createQuery();
+ AuditQueryCreator createQuery();
}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,8 +26,8 @@
import javax.persistence.EntityManager;
import org.hibernate.envers.event.VersionsEventListener;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.reader.VersionsReaderImpl;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.reader.AuditReaderImpl;
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
import org.hibernate.Session;
@@ -48,9 +48,9 @@
* @param session An open session.
* @return A versions reader associated with the given sesison. It shouldn't be
used
* after the session is closed.
- * @throws VersionsException When the given required listeners aren't installed.
+ * @throws org.hibernate.envers.exception.AuditException When the given required
listeners aren't installed.
*/
- public static AuditReader get(Session session) throws VersionsException {
+ public static AuditReader get(Session session) throws AuditException {
SessionImplementor sessionImpl = (SessionImplementor) session;
EventListeners listeners = sessionImpl.getListeners();
@@ -59,13 +59,13 @@
if (listener instanceof VersionsEventListener) {
if (arrayIncludesInstanceOf(listeners.getPostUpdateEventListeners(),
VersionsEventListener.class) &&
arrayIncludesInstanceOf(listeners.getPostDeleteEventListeners(),
VersionsEventListener.class)) {
- return new VersionsReaderImpl(((VersionsEventListener)
listener).getVerCfg(), session,
+ return new AuditReaderImpl(((VersionsEventListener)
listener).getVerCfg(), session,
sessionImpl);
}
}
}
- throw new VersionsException("You need install the
org.hibernate.envers.event.VersionsEventListener " +
+ throw new AuditException("You need install the
org.hibernate.envers.event.VersionsEventListener " +
"class as post insert, update and delete event listener.");
}
@@ -74,10 +74,10 @@
* @param entityManager An open entity manager.
* @return A versions reader associated with the given entity manager. It
shouldn't be used
* after the entity manager is closed.
- * @throws VersionsException When the given entity manager is not based on Hibernate,
or if the required
+ * @throws org.hibernate.envers.exception.AuditException When the given entity
manager is not based on Hibernate, or if the required
* listeners aren't installed.
*/
- public static AuditReader get(EntityManager entityManager) throws VersionsException
{
+ public static AuditReader get(EntityManager entityManager) throws AuditException {
if (entityManager.getDelegate() instanceof Session) {
return get((Session) entityManager.getDelegate());
}
@@ -88,6 +88,6 @@
}
}
- throw new VersionsException("Hibernate EntityManager not present!");
+ throw new AuditException("Hibernate EntityManager not present!");
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/ant/AnnotationConfigurationTaskWithEnvers.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/ant/AnnotationConfigurationTaskWithEnvers.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/ant/AnnotationConfigurationTaskWithEnvers.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.ant;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.ant.AnnotationConfigurationTask;
@@ -33,7 +33,7 @@
*/
public class AnnotationConfigurationTaskWithEnvers extends AnnotationConfigurationTask {
protected void doConfiguration(Configuration configuration) {
- VersionsConfiguration.getFor(configuration);
+ AuditConfiguration.getFor(configuration);
super.doConfiguration(configuration);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/ant/ConfigurationTaskWithEnvers.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/ant/ConfigurationTaskWithEnvers.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/ant/ConfigurationTaskWithEnvers.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.ant;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.ant.ConfigurationTask;
@@ -33,7 +33,7 @@
*/
public class ConfigurationTaskWithEnvers extends ConfigurationTask {
protected void doConfiguration(Configuration configuration) {
- VersionsConfiguration.getFor(configuration);
+ AuditConfiguration.getFor(configuration);
super.doConfiguration(configuration);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/ant/JPAConfigurationTaskWithEnvers.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/ant/JPAConfigurationTaskWithEnvers.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/ant/JPAConfigurationTaskWithEnvers.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.ant;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.ant.JPAConfigurationTask;
@@ -33,7 +33,7 @@
*/
public class JPAConfigurationTaskWithEnvers extends JPAConfigurationTask {
protected void doConfiguration(Configuration configuration) {
- VersionsConfiguration.getFor(configuration);
+ AuditConfiguration.getFor(configuration);
super.doConfiguration(configuration);
}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/VersionsConfiguration.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,106 @@
+/*
+ * 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.configuration;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.WeakHashMap;
+
+import org.hibernate.envers.entities.EntitiesConfigurations;
+import org.hibernate.envers.revisioninfo.RevisionInfoNumberReader;
+import org.hibernate.envers.revisioninfo.RevisionInfoQueryCreator;
+import org.hibernate.envers.synchronization.AuditSyncManager;
+import org.hibernate.envers.tools.reflection.YReflectionManager;
+
+import org.hibernate.cfg.Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditConfiguration {
+ private final GlobalConfiguration globalCfg;
+ private final AuditEntitiesConfiguration verEntCfg;
+ private final AuditSyncManager versionsSyncManager;
+ private final EntitiesConfigurations entCfg;
+ private final RevisionInfoQueryCreator revisionInfoQueryCreator;
+ private final RevisionInfoNumberReader revisionInfoNumberReader;
+
+ public AuditEntitiesConfiguration getVerEntCfg() {
+ return verEntCfg;
+ }
+
+ public AuditSyncManager getSyncManager() {
+ return versionsSyncManager;
+ }
+
+ public GlobalConfiguration getGlobalCfg() {
+ return globalCfg;
+ }
+
+ public EntitiesConfigurations getEntCfg() {
+ return entCfg;
+ }
+
+ public RevisionInfoQueryCreator getRevisionInfoQueryCreator() {
+ return revisionInfoQueryCreator;
+ }
+
+ public RevisionInfoNumberReader getRevisionInfoNumberReader() {
+ return revisionInfoNumberReader;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public AuditConfiguration(Configuration cfg) {
+ Properties properties = cfg.getProperties();
+
+ YReflectionManager reflectionManager = YReflectionManager.get(cfg);
+ RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration();
+ RevisionInfoConfigurationResult revInfoCfgResult = revInfoCfg.configure(cfg,
reflectionManager);
+ verEntCfg = new AuditEntitiesConfiguration(properties,
revInfoCfgResult.getRevisionInfoEntityName());
+ globalCfg = new GlobalConfiguration(properties);
+ versionsSyncManager = new
AuditSyncManager(revInfoCfgResult.getRevisionInfoGenerator());
+ revisionInfoQueryCreator = revInfoCfgResult.getRevisionInfoQueryCreator();
+ revisionInfoNumberReader = revInfoCfgResult.getRevisionInfoNumberReader();
+ entCfg = new EntitiesConfigurator().configure(cfg, reflectionManager, globalCfg,
verEntCfg,
+ revInfoCfgResult.getRevisionInfoXmlMapping(),
revInfoCfgResult.getRevisionInfoRelationMapping());
+ }
+
+ //
+
+ private static Map<Configuration, AuditConfiguration> cfgs
+ = new WeakHashMap<Configuration, AuditConfiguration>();
+
+ public synchronized static AuditConfiguration getFor(Configuration cfg) {
+ AuditConfiguration verCfg = cfgs.get(cfg);
+
+ if (verCfg == null) {
+ verCfg = new AuditConfiguration(cfg);
+ cfgs.put(cfg, verCfg);
+
+ cfg.buildMappings();
+ }
+
+ return verCfg;
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/VersionsEntitiesConfiguration.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,112 @@
+/*
+ * 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.configuration;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Configuration of versions entities - names of fields, entities and tables created to
store versioning information.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditEntitiesConfiguration {
+ private final String versionsTablePrefix;
+ private final String versionsTableSuffix;
+
+ private final String originalIdPropName;
+
+ private final String revisionPropName;
+ private final String revisionPropPath;
+
+ private final String revisionTypePropName;
+ private final String revisionTypePropType;
+
+ private final String revisionInfoEntityName;
+
+ private final Map<String, String> customVersionsTablesNames;
+
+ public AuditEntitiesConfiguration(Properties properties, String
revisionInfoEntityName) {
+ this.revisionInfoEntityName = revisionInfoEntityName;
+
+ versionsTablePrefix =
properties.getProperty("org.hibernate.envers.versionsTablePrefix",
"");
+ versionsTableSuffix =
properties.getProperty("org.hibernate.envers.versionsTableSuffix",
"_versions");
+
+ originalIdPropName = "originalId";
+
+ revisionPropName =
properties.getProperty("org.hibernate.envers.revisionFieldName",
"_revision");
+
+ revisionTypePropName =
properties.getProperty("org.hibernate.envers.revisionTypeFieldName",
"_revision_type");
+ revisionTypePropType = "byte";
+
+ customVersionsTablesNames = new HashMap<String, String>();
+
+ revisionPropPath = originalIdPropName + "." + revisionPropName +
".id";
+ }
+
+ public String getOriginalIdPropName() {
+ return originalIdPropName;
+ }
+
+ public String getRevisionPropName() {
+ return revisionPropName;
+ }
+
+ public String getRevisionPropPath() {
+ return revisionPropPath;
+ }
+
+ public String getRevisionTypePropName() {
+ return revisionTypePropName;
+ }
+
+ public String getRevisionTypePropType() {
+ return revisionTypePropType;
+ }
+
+ public String getRevisionInfoEntityName() {
+ return revisionInfoEntityName;
+ }
+
+ //
+
+ public void addCustomVersionsTableName(String entityName, String tableName) {
+ customVersionsTablesNames.put(entityName, tableName);
+ }
+
+ //
+
+ public String getVersionsEntityName(String entityName) {
+ return versionsTablePrefix + entityName + versionsTableSuffix;
+ }
+
+ public String getVersionsTableName(String entityName, String tableName) {
+ String customHistoryTableName = customVersionsTablesNames.get(entityName);
+ if (customHistoryTableName == null) {
+ return versionsTablePrefix + tableName + versionsTableSuffix;
+ }
+
+ 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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -40,7 +40,7 @@
import org.hibernate.envers.configuration.metadata.AnnotationsMetadataReader;
import org.hibernate.envers.configuration.metadata.EntityXmlMappingData;
import org.hibernate.envers.configuration.metadata.PersistentClassVersioningData;
-import org.hibernate.envers.configuration.metadata.VersionsMetadataGenerator;
+import org.hibernate.envers.configuration.metadata.AuditMetadataGenerator;
import org.hibernate.envers.entities.EntitiesConfigurations;
import org.hibernate.envers.tools.StringTools;
import org.hibernate.envers.tools.graph.GraphTopologicalSort;
@@ -55,9 +55,9 @@
*/
public class EntitiesConfigurator {
public EntitiesConfigurations configure(Configuration cfg, YReflectionManager
reflectionManager,
- GlobalConfiguration globalCfg,
VersionsEntitiesConfiguration verEntCfg,
+ GlobalConfiguration globalCfg,
AuditEntitiesConfiguration verEntCfg,
Document revisionInfoXmlMapping, Element
revisionInfoRelationMapping) {
- VersionsMetadataGenerator versionsMetaGen = new VersionsMetadataGenerator(cfg,
globalCfg, verEntCfg,
+ AuditMetadataGenerator versionsMetaGen = new AuditMetadataGenerator(cfg,
globalCfg, verEntCfg,
revisionInfoRelationMapping);
DOMWriter writer = new DOMWriter();
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
(from rev 15459,
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/VersionsMetadataGenerator.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,385 @@
+/*
+ * 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.configuration.metadata;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Element;
+import org.hibernate.envers.ModificationStore;
+import org.hibernate.envers.AuditJoinTable;
+import org.hibernate.envers.configuration.GlobalConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
+import org.hibernate.envers.entities.EntityConfiguration;
+import org.hibernate.envers.entities.IdMappingData;
+import org.hibernate.envers.entities.mapper.CompositeMapperBuilder;
+import org.hibernate.envers.entities.mapper.ExtendedPropertyMapper;
+import org.hibernate.envers.entities.mapper.MultiPropertyMapper;
+import org.hibernate.envers.entities.mapper.SubclassPropertyMapper;
+import org.hibernate.envers.entity.VersionsInheritanceEntityPersister;
+import org.hibernate.envers.tools.StringTools;
+import org.hibernate.envers.tools.log.YLog;
+import org.hibernate.envers.tools.log.YLogManager;
+
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.CollectionType;
+import org.hibernate.type.ManyToOneType;
+import org.hibernate.type.OneToOneType;
+import org.hibernate.type.Type;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ * @author Sebastian Komander
+ */
+public final class AuditMetadataGenerator {
+ private final Configuration cfg;
+ private final GlobalConfiguration globalCfg;
+ private final AuditEntitiesConfiguration verEntCfg;
+ private final Element revisionInfoRelationMapping;
+
+ private final BasicMetadataGenerator basicMetadataGenerator;
+ private final IdMetadataGenerator idMetadataGenerator;
+ private final ToOneRelationMetadataGenerator toOneRelationMetadataGenerator;
+
+ private final Map<String, EntityConfiguration> entitiesConfigurations;
+
+ // Map entity name -> (join descriptor -> element describing the
"versioned" join)
+ private final Map<String, Map<Join, Element>> entitiesJoins;
+
+ private YLog log = YLogManager.getLogManager().getLog(AuditMetadataGenerator.class);
+
+ public AuditMetadataGenerator(Configuration cfg, GlobalConfiguration globalCfg,
+ AuditEntitiesConfiguration verEntCfg,
+ Element revisionInfoRelationMapping) {
+ this.cfg = cfg;
+ this.globalCfg = globalCfg;
+ this.verEntCfg = verEntCfg;
+ this.revisionInfoRelationMapping = revisionInfoRelationMapping;
+
+ this.basicMetadataGenerator = new BasicMetadataGenerator();
+ this.idMetadataGenerator = new IdMetadataGenerator(this);
+ this.toOneRelationMetadataGenerator = new ToOneRelationMetadataGenerator(this);
+
+ entitiesConfigurations = new HashMap<String, EntityConfiguration>();
+ entitiesJoins = new HashMap<String, Map<Join, Element>>();
+ }
+
+ void addRevisionInfoRelation(Element any_mapping) {
+ Element rev_mapping = (Element) revisionInfoRelationMapping.clone();
+ rev_mapping.addAttribute("name", verEntCfg.getRevisionPropName());
+ MetadataTools.addColumn(rev_mapping, verEntCfg.getRevisionPropName(), null);
+
+ any_mapping.add(rev_mapping);
+ }
+
+ void addRevisionType(Element any_mapping) {
+ Element revTypeProperty = MetadataTools.addProperty(any_mapping,
verEntCfg.getRevisionTypePropName(),
+ verEntCfg.getRevisionTypePropType(), true, false);
+ revTypeProperty.addAttribute("type",
"org.hibernate.envers.entities.RevisionTypeType");
+ }
+
+ private ModificationStore getStoreForProperty(Property property, PropertyStoreInfo
propertyStoreInfo,
+ List<String>
unversionedProperties) {
+ /*
+ * Checks if a property is versioned, which is when:
+ * - the property isn't unversioned
+ * - the whole entity is versioned, then the default store is not null
+ * - there is a store defined for this entity, which is when this property is
annotated
+ */
+
+ if (unversionedProperties.contains(property.getName())) {
+ return null;
+ }
+
+ ModificationStore store =
propertyStoreInfo.propertyStores.get(property.getName());
+
+ if (store == null) {
+ return propertyStoreInfo.defaultStore;
+ }
+
+ return store;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ void addValue(Element parent, String name, Value value, CompositeMapperBuilder
currentMapper,
+ ModificationStore store, String entityName, EntityXmlMappingData
xmlMappingData,
+ AuditJoinTable joinTable, String mapKey, boolean insertable, boolean
firstPass) {
+ Type type = value.getType();
+
+ // only first pass
+ if (firstPass) {
+ if (basicMetadataGenerator.addBasic(parent, name, value, currentMapper,
store, entityName, insertable,
+ false)) {
+ // The property was mapped by the basic generator.
+ return;
+ }
+ }
+
+ if (type instanceof ManyToOneType) {
+ // only second pass
+ if (!firstPass) {
+ toOneRelationMetadataGenerator.addToOne(parent, name, value,
currentMapper, entityName);
+ }
+ } else if (type instanceof OneToOneType) {
+ // only second pass
+ if (!firstPass) {
+ toOneRelationMetadataGenerator.addOneToOneNotOwning(name, value,
currentMapper, entityName);
+ }
+ } else if (type instanceof CollectionType) {
+ // only second pass
+ if (!firstPass) {
+ CollectionMetadataGenerator collectionMetadataGenerator = new
CollectionMetadataGenerator(this,
+ name, (Collection) value, currentMapper, entityName,
xmlMappingData, joinTable, mapKey);
+ collectionMetadataGenerator.addCollection();
+ }
+ } else {
+ if (firstPass) {
+ // If we got here in the first pass, it means the basic mapper didn't
map it, and none of the
+ // above branches either.
+ throwUnsupportedTypeException(type, entityName, name);
+ }
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private void addProperties(Element parent, Iterator<Property> properties,
CompositeMapperBuilder currentMapper,
+ PersistentClassVersioningData versioningData, String
entityName, EntityXmlMappingData xmlMappingData,
+ boolean firstPass) {
+ while (properties.hasNext()) {
+ Property property = properties.next();
+ if (!"_identifierMapper".equals(property.getName())) {
+ ModificationStore store = getStoreForProperty(property,
versioningData.propertyStoreInfo,
+ versioningData.unversionedProperties);
+
+ if (store != null) {
+ addValue(parent, property.getName(), property.getValue(),
currentMapper, store, entityName,
+ xmlMappingData,
versioningData.versionsJoinTables.get(property.getName()),
+ versioningData.mapKeys.get(property.getName()),
property.isInsertable(), firstPass);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private void createJoins(PersistentClass pc, Element parent,
PersistentClassVersioningData versioningData) {
+ Iterator<Join> joins = pc.getJoinIterator();
+
+ Map<Join, Element> joinElements = new HashMap<Join, Element>();
+ entitiesJoins.put(pc.getEntityName(), joinElements);
+
+ while (joins.hasNext()) {
+ Join join = joins.next();
+
+ // 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.secondaryTableDictionary.get(originalTableName);
+ if (versionedTableName == null) {
+ versionedTableName = verEntCfg.getVersionsEntityName(originalTableName);
+ }
+
+ String schema = versioningData.versionsTable.schema();
+ if (StringTools.isEmpty(schema)) {
+ schema = join.getTable().getSchema();
+ }
+
+ String catalog = versioningData.versionsTable.catalog();
+ if (StringTools.isEmpty(catalog)) {
+ catalog = join.getTable().getCatalog();
+ }
+
+ Element joinElement = MetadataTools.createJoin(parent, versionedTableName,
schema, catalog);
+ joinElements.put(join, joinElement);
+
+ Element joinKey = joinElement.addElement("key");
+ MetadataTools.addColumns(joinKey, join.getKey().getColumnIterator());
+ MetadataTools.addColumn(joinKey, verEntCfg.getRevisionPropName(), null);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private void addJoins(PersistentClass pc, CompositeMapperBuilder currentMapper,
PersistentClassVersioningData versioningData,
+ String entityName, EntityXmlMappingData xmlMappingData,boolean
firstPass) {
+ Iterator<Join> joins = pc.getJoinIterator();
+
+ while (joins.hasNext()) {
+ Join join = joins.next();
+ Element joinElement = entitiesJoins.get(entityName).get(join);
+
+ addProperties(joinElement, join.getPropertyIterator(), currentMapper,
versioningData, entityName,
+ xmlMappingData, firstPass);
+ }
+ }
+
+ private void addPersisterHack(Element class_mapping) {
+ class_mapping.addAttribute("persister",
VersionsInheritanceEntityPersister.class.getName() );
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void generateFirstPass(PersistentClass pc, PersistentClassVersioningData
versioningData,
+ EntityXmlMappingData xmlMappingData) {
+ String schema = versioningData.versionsTable.schema();
+ if (StringTools.isEmpty(schema)) {
+ schema = pc.getTable().getSchema();
+ }
+
+ String catalog = versioningData.versionsTable.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());
+
+ // Generating a mapping for the id
+ IdMappingData idMapper = idMetadataGenerator.addId(pc);
+
+ Element class_mapping;
+ ExtendedPropertyMapper propertyMapper;
+
+ InheritanceType inheritanceType = InheritanceType.get(pc);
+ String parentEntityName = null;
+
+ switch (inheritanceType) {
+ case NONE:
+ class_mapping =
MetadataTools.createEntity(xmlMappingData.getMainXmlMapping(), versionsEntityName,
versionsTableName,
+ schema, catalog, pc.getDiscriminatorValue());
+ propertyMapper = new MultiPropertyMapper();
+
+ // Checking if there is a discriminator column
+ if (pc.getDiscriminator() != null) {
+ Element discriminator_element =
class_mapping.addElement("discriminator");
+ MetadataTools.addColumns(discriminator_element,
pc.getDiscriminator().getColumnIterator());
+ discriminator_element.addAttribute("type",
pc.getDiscriminator().getType().getName());
+
+ // If so, there is some inheritance scheme -> using the persister
hack.
+ addPersisterHack(class_mapping);
+ }
+
+ // Adding the id mapping
+ class_mapping.add((Element) idMapper.getXmlMapping().clone());
+
+ // Adding the "revision type" property
+ addRevisionType(class_mapping);
+
+ break;
+ case SINGLE:
+ String extendsEntityName =
verEntCfg.getVersionsEntityName(pc.getSuperclass().getEntityName());
+ class_mapping =
MetadataTools.createSubclassEntity(xmlMappingData.getMainXmlMapping(),
versionsEntityName,
+ versionsTableName, schema, catalog, extendsEntityName,
pc.getDiscriminatorValue());
+
+ addPersisterHack(class_mapping);
+
+ // The id and revision type is already mapped in the parent
+
+ // Getting the property mapper of the parent - when mapping properties,
they need to be included
+ parentEntityName = pc.getSuperclass().getEntityName();
+ ExtendedPropertyMapper parentPropertyMapper =
entitiesConfigurations.get(parentEntityName).getPropertyMapper();
+ propertyMapper = new SubclassPropertyMapper(new MultiPropertyMapper(),
parentPropertyMapper);
+
+ break;
+ case JOINED:
+ throw new MappingException("Joined inheritance strategy not
supported for versioning!");
+ case TABLE_PER_CLASS:
+ throw new MappingException("Table-per-class inheritance strategy not
supported for versioning!");
+ default:
+ throw new AssertionError("Impossible enum value.");
+ }
+
+ // Mapping unjoined properties
+ addProperties(class_mapping, (Iterator<Property>)
pc.getUnjoinedPropertyIterator(), propertyMapper,
+ versioningData, pc.getEntityName(), xmlMappingData,
+ true);
+
+ // Creating and mapping joins (first pass)
+ createJoins(pc, class_mapping, versioningData);
+ addJoins(pc, propertyMapper, versioningData, pc.getEntityName(), xmlMappingData,
true);
+
+ // Storing the generated configuration
+ EntityConfiguration entityCfg = new EntityConfiguration(versionsEntityName,
idMapper,
+ propertyMapper, parentEntityName);
+ entitiesConfigurations.put(pc.getEntityName(), entityCfg);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void generateSecondPass(PersistentClass pc, PersistentClassVersioningData
versioningData,
+ EntityXmlMappingData xmlMappingData) {
+ String entityName = pc.getEntityName();
+
+ CompositeMapperBuilder propertyMapper =
entitiesConfigurations.get(entityName).getPropertyMapper();
+
+ // Mapping unjoined properties
+ Element parent =
xmlMappingData.getMainXmlMapping().getRootElement().element("class");
+ if (parent == null) {
+ parent =
xmlMappingData.getMainXmlMapping().getRootElement().element("subclass");
+ }
+
+ addProperties(parent, (Iterator<Property>)
pc.getUnjoinedPropertyIterator(),
+ propertyMapper, versioningData, entityName, xmlMappingData, false);
+
+ // Mapping joins (second pass)
+ addJoins(pc, propertyMapper, versioningData, entityName, xmlMappingData, false);
+ }
+
+ public Map<String, EntityConfiguration> getEntitiesConfigurations() {
+ return entitiesConfigurations;
+ }
+
+ // Getters for generators and configuration
+
+ BasicMetadataGenerator getBasicMetadataGenerator() {
+ return basicMetadataGenerator;
+ }
+
+ Configuration getCfg() {
+ return cfg;
+ }
+
+ GlobalConfiguration getGlobalCfg() {
+ return globalCfg;
+ }
+
+ AuditEntitiesConfiguration getVerEntCfg() {
+ return verEntCfg;
+ }
+
+ void throwUnsupportedTypeException(Type type, String entityName, String propertyName)
{
+ String message = "Type not supported for versioning: " +
type.getClass().getName() +
+ ", on entity " + entityName + ", property '" +
propertyName + "'.";
+ if (globalCfg.isWarnOnUnsupportedTypes()) {
+ log.warn(message);
+ } else {
+ throw new MappingException(message);
+ }
+ }
+}
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -85,7 +85,7 @@
* @author Adam Warski (adam at warski dot org)
*/
public final class CollectionMetadataGenerator {
- private final VersionsMetadataGenerator mainGenerator;
+ private final AuditMetadataGenerator mainGenerator;
private final String propertyName;
private final Collection propertyValue;
private final CompositeMapperBuilder currentMapper;
@@ -113,7 +113,7 @@
* @param mapKey The value of the name() property of the MapKey annotation on this
property. Null, if this
* property isn't annotated with this annotation.
*/
- public CollectionMetadataGenerator(VersionsMetadataGenerator mainGenerator, String
propertyName,
+ public CollectionMetadataGenerator(AuditMetadataGenerator mainGenerator, String
propertyName,
Collection propertyValue, CompositeMapperBuilder
currentMapper,
String referencingEntityName, EntityXmlMappingData
xmlMappingData,
AuditJoinTable joinTable, String mapKey) {
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/IdMetadataGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -47,9 +47,9 @@
* @author Adam Warski (adam at warski dot org)
*/
public final class IdMetadataGenerator {
- private final VersionsMetadataGenerator mainGenerator;
+ private final AuditMetadataGenerator mainGenerator;
- IdMetadataGenerator(VersionsMetadataGenerator versionsMetadataGenerator) {
+ IdMetadataGenerator(AuditMetadataGenerator versionsMetadataGenerator) {
mainGenerator = versionsMetadataGenerator;
}
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/QueryGeneratorBuilder.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,7 +27,7 @@
import java.util.List;
import org.hibernate.envers.configuration.GlobalConfiguration;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.MiddleIdData;
import org.hibernate.envers.entities.mapper.relation.query.OneEntityQueryGenerator;
@@ -42,12 +42,12 @@
*/
public final class QueryGeneratorBuilder {
private final GlobalConfiguration globalCfg;
- private final VersionsEntitiesConfiguration verEntCfg;
+ private final AuditEntitiesConfiguration verEntCfg;
private final MiddleIdData referencingIdData;
private final String versionsMiddleEntityName;
private final List<MiddleIdData> idDatas;
- QueryGeneratorBuilder(GlobalConfiguration globalCfg, VersionsEntitiesConfiguration
verEntCfg,
+ QueryGeneratorBuilder(GlobalConfiguration globalCfg, AuditEntitiesConfiguration
verEntCfg,
MiddleIdData referencingIdData, String
versionsMiddleEntityName) {
this.globalCfg = globalCfg;
this.verEntCfg = verEntCfg;
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/ToOneRelationMetadataGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -41,9 +41,9 @@
* @author Adam Warski (adam at warski dot org)
*/
public final class ToOneRelationMetadataGenerator {
- private final VersionsMetadataGenerator mainGenerator;
+ private final AuditMetadataGenerator mainGenerator;
- ToOneRelationMetadataGenerator(VersionsMetadataGenerator versionsMetadataGenerator)
{
+ ToOneRelationMetadataGenerator(AuditMetadataGenerator versionsMetadataGenerator) {
mainGenerator = versionsMetadataGenerator;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/EntityInstantiator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/EntityInstantiator.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/EntityInstantiator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,20 +27,20 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.id.IdMapper;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.reflection.ReflectionTools;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class EntityInstantiator {
- private final VersionsConfiguration verCfg;
- private final VersionsReaderImplementor versionsReader;
+ private final AuditConfiguration verCfg;
+ private final AuditReaderImplementor versionsReader;
- public EntityInstantiator(VersionsConfiguration verCfg, VersionsReaderImplementor
versionsReader) {
+ public EntityInstantiator(AuditConfiguration verCfg, AuditReaderImplementor
versionsReader) {
this.verCfg = verCfg;
this.versionsReader = versionsReader;
}
@@ -82,7 +82,7 @@
Class<?> cls = ReflectionTools.loadClass(entityName);
ret = cls.newInstance();
} catch (Exception e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
// Putting the newly created entity instance into the first level cache, in case
a one-to-one bidirectional
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MapPropertyMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MapPropertyMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MapPropertyMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -29,9 +29,9 @@
import java.util.Map;
import org.hibernate.envers.ModificationStore;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.reflection.ReflectionTools;
import org.hibernate.collection.PersistentCollection;
@@ -70,7 +70,7 @@
return delegate.mapToMapFromEntity(newData, newObj, oldObj);
}
- public void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data,
Object primaryKey, VersionsReaderImplementor versionsReader, Number revision) {
+ public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data,
Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
if (data == null || obj == null) {
return;
}
@@ -83,7 +83,7 @@
setter.set(obj, subObj, null);
delegate.mapToEntityFromMap(verCfg, subObj, (Map) data.get(propertyName),
primaryKey, versionsReader, revision);
} catch (Exception e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MultiPropertyMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MultiPropertyMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/MultiPropertyMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -29,8 +29,8 @@
import java.util.Map;
import org.hibernate.envers.ModificationStore;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.reflection.ReflectionTools;
import org.hibernate.MappingException;
@@ -105,7 +105,7 @@
return ret;
}
- public void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data,
Object primaryKey, VersionsReaderImplementor versionsReader, Number revision) {
+ public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data,
Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
for (String propertyName : properties.keySet()) {
properties.get(propertyName).mapToEntityFromMap(verCfg, obj, data,
primaryKey, versionsReader, revision);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/PropertyMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/PropertyMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/PropertyMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,8 +27,8 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.collection.PersistentCollection;
@@ -54,8 +54,8 @@
* @param versionsReader VersionsReader for reading relations
* @param revision Revision at which the object is read, for reading relations
*/
- void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data, Object
primaryKey,
- VersionsReaderImplementor versionsReader, Number revision);
+ void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data, Object
primaryKey,
+ AuditReaderImplementor versionsReader, Number revision);
/**
* Maps collection changes
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SinglePropertyMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SinglePropertyMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SinglePropertyMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,9 +28,9 @@
import java.util.Map;
import org.hibernate.envers.ModificationStore;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.Tools;
import org.hibernate.envers.tools.reflection.ReflectionTools;
@@ -48,7 +48,7 @@
public void add(String propertyName, ModificationStore modStore) {
if (this.propertyName != null) {
- throw new VersionsException("Only one property can be added!");
+ throw new AuditException("Only one property can be added!");
}
this.propertyName = propertyName;
@@ -60,7 +60,7 @@
return !Tools.objectsEqual(newObj, oldObj);
}
- public void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data,
Object primaryKey, VersionsReaderImplementor versionsReader, Number revision) {
+ public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data,
Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
if (data == null || obj == null) {
return;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SubclassPropertyMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SubclassPropertyMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/SubclassPropertyMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,8 +28,8 @@
import java.util.Map;
import org.hibernate.envers.ModificationStore;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.collection.PersistentCollection;
@@ -61,7 +61,7 @@
return parentDiffs || mainDiffs;
}
- public void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data,
Object primaryKey, VersionsReaderImplementor versionsReader, Number revision) {
+ public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data,
Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
parentMapper.mapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader,
revision);
main.mapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader,
revision);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/AbstractCompositeIdMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/AbstractCompositeIdMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/AbstractCompositeIdMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,7 +27,7 @@
import java.util.Map;
import org.hibernate.envers.ModificationStore;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* @author Adam Warski (adam at warski dot org)
@@ -51,7 +51,7 @@
try {
ret =
Thread.currentThread().getContextClassLoader().loadClass(compositeIdClass).newInstance();
} catch (Exception e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
for (SingleIdMapper mapper : ids.values()) {
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/EmbeddedIdMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/EmbeddedIdMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/EmbeddedIdMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.tools.reflection.ReflectionTools;
import org.hibernate.property.Getter;
@@ -78,7 +78,7 @@
idMapper.mapToEntityFromMap(subObj, data);
}
} catch (Exception e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/MultipleIdMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/MultipleIdMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/MultipleIdMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* @author Adam Warski (adam at warski dot org)
@@ -73,7 +73,7 @@
try {
ret =
Thread.currentThread().getContextClassLoader().loadClass(compositeIdClass).newInstance();
} catch (Exception e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
for (SingleIdMapper mapper : ids.values()) {
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/SingleIdMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/SingleIdMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/id/SingleIdMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.Map;
import org.hibernate.envers.ModificationStore;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.tools.reflection.ReflectionTools;
import org.hibernate.property.Getter;
@@ -56,7 +56,7 @@
public void add(String propertyName, ModificationStore modStore) {
if (this.propertyName != null) {
- throw new VersionsException("Only one property can be added!");
+ throw new AuditException("Only one property can be added!");
}
this.propertyName = propertyName;
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/AbstractCollectionMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/AbstractCollectionMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/AbstractCollectionMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -35,12 +35,12 @@
import java.util.Set;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
import org.hibernate.envers.entities.mapper.PropertyMapper;
import org.hibernate.envers.entities.mapper.relation.lazy.initializor.Initializor;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.reflection.ReflectionTools;
import org.hibernate.collection.PersistentCollection;
@@ -63,7 +63,7 @@
try {
proxyConstructor = proxyClass.getConstructor(Initializor.class);
} catch (NoSuchMethodException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -131,22 +131,22 @@
return false;
}
- protected abstract Initializor<T> getInitializor(VersionsConfiguration verCfg,
- VersionsReaderImplementor
versionsReader, Object primaryKey,
+ protected abstract Initializor<T> getInitializor(AuditConfiguration verCfg,
+ AuditReaderImplementor
versionsReader, Object primaryKey,
Number revision);
- public void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data,
Object primaryKey,
- VersionsReaderImplementor versionsReader, Number
revision) {
+ public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data,
Object primaryKey,
+ AuditReaderImplementor versionsReader, Number
revision) {
Setter setter = ReflectionTools.getSetter(obj.getClass(),
commonCollectionMapperData.getCollectionReferencingPropertyName());
try {
setter.set(obj, proxyConstructor.newInstance(getInitializor(verCfg,
versionsReader, primaryKey, revision)), null);
} catch (InstantiationException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/BasicCollectionMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/BasicCollectionMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/BasicCollectionMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,11 +27,11 @@
import java.util.Collection;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.PropertyMapper;
import
org.hibernate.envers.entities.mapper.relation.lazy.initializor.BasicCollectionInitializor;
import org.hibernate.envers.entities.mapper.relation.lazy.initializor.Initializor;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.collection.PersistentCollection;
@@ -48,7 +48,7 @@
this.elementComponentData = elementComponentData;
}
- protected Initializor<T> getInitializor(VersionsConfiguration verCfg,
VersionsReaderImplementor versionsReader,
+ protected Initializor<T> getInitializor(AuditConfiguration verCfg,
AuditReaderImplementor versionsReader,
Object primaryKey, Number revision) {
return new BasicCollectionInitializor<T>(verCfg, versionsReader,
commonCollectionMapperData.getQueryGenerator(),
primaryKey, revision, collectionClass, elementComponentData);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/CommonCollectionMapperData.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/CommonCollectionMapperData.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/CommonCollectionMapperData.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.entities.mapper.relation;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.mapper.relation.query.RelationQueryGenerator;
/**
@@ -31,13 +31,13 @@
* @author Adam Warski (adam at warski dot org)
*/
public final class CommonCollectionMapperData {
- private final VersionsEntitiesConfiguration verEntCfg;
+ private final AuditEntitiesConfiguration verEntCfg;
private final String versionsMiddleEntityName;
private final String collectionReferencingPropertyName;
private final MiddleIdData referencingIdData;
private final RelationQueryGenerator queryGenerator;
- public CommonCollectionMapperData(VersionsEntitiesConfiguration verEntCfg, String
versionsMiddleEntityName,
+ public CommonCollectionMapperData(AuditEntitiesConfiguration verEntCfg, String
versionsMiddleEntityName,
String collectionReferencingPropertyName,
MiddleIdData referencingIdData,
RelationQueryGenerator queryGenerator) {
this.verEntCfg = verEntCfg;
@@ -47,7 +47,7 @@
this.queryGenerator = queryGenerator;
}
- public VersionsEntitiesConfiguration getVerEntCfg() {
+ public AuditEntitiesConfiguration getVerEntCfg() {
return verEntCfg;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ListCollectionMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ListCollectionMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ListCollectionMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,12 +28,12 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.PropertyMapper;
import org.hibernate.envers.entities.mapper.relation.lazy.initializor.Initializor;
import
org.hibernate.envers.entities.mapper.relation.lazy.initializor.ListCollectionInitializor;
import org.hibernate.envers.entities.mapper.relation.lazy.proxy.ListProxy;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.Pair;
import org.hibernate.envers.tools.Tools;
@@ -53,7 +53,7 @@
this.indexComponentData = indexComponentData;
}
- protected Initializor<List> getInitializor(VersionsConfiguration verCfg,
VersionsReaderImplementor versionsReader,
+ protected Initializor<List> getInitializor(AuditConfiguration verCfg,
AuditReaderImplementor versionsReader,
Object primaryKey, Number revision) {
return new ListCollectionInitializor(verCfg, versionsReader,
commonCollectionMapperData.getQueryGenerator(),
primaryKey, revision, elementComponentData, indexComponentData);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MapCollectionMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MapCollectionMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MapCollectionMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,11 +27,11 @@
import java.util.Collection;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.PropertyMapper;
import org.hibernate.envers.entities.mapper.relation.lazy.initializor.Initializor;
import
org.hibernate.envers.entities.mapper.relation.lazy.initializor.MapCollectionInitializor;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.collection.PersistentCollection;
@@ -50,7 +50,7 @@
this.indexComponentData = indexComponentData;
}
- protected Initializor<T> getInitializor(VersionsConfiguration verCfg,
VersionsReaderImplementor versionsReader,
+ protected Initializor<T> getInitializor(AuditConfiguration verCfg,
AuditReaderImplementor versionsReader,
Object primaryKey, Number revision) {
return new MapCollectionInitializor<T>(verCfg, versionsReader,
commonCollectionMapperData.getQueryGenerator(),
primaryKey, revision, collectionClass, elementComponentData,
indexComponentData);
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/MiddleIdData.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.entities.mapper.relation;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.IdMappingData;
import org.hibernate.envers.entities.mapper.id.IdMapper;
@@ -50,7 +50,7 @@
*/
private final String versionsEntityName;
- public MiddleIdData(VersionsEntitiesConfiguration verEntCfg, IdMappingData
mappingData, String prefix,
+ public MiddleIdData(AuditEntitiesConfiguration verEntCfg, IdMappingData mappingData,
String prefix,
String entityName) {
this.originalMapper = mappingData.getIdMapper();
this.prefixedMapper = mappingData.getIdMapper().prefixMappedProperties(prefix);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/OneToOneNotOwningMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/OneToOneNotOwningMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/OneToOneNotOwningMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,12 +28,12 @@
import java.util.Map;
import javax.persistence.NoResultException;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
import org.hibernate.envers.entities.mapper.PropertyMapper;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.query.VersionsRestrictions;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.reflection.ReflectionTools;
import org.hibernate.NonUniqueResultException;
@@ -58,7 +58,7 @@
return false;
}
- public void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data,
Object primaryKey, VersionsReaderImplementor versionsReader, Number revision) {
+ public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data,
Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
if (obj == null) {
return;
}
@@ -69,11 +69,11 @@
try {
value = versionsReader.createQuery().forEntitiesAtRevision(entityClass,
revision)
- .add(VersionsRestrictions.relatedIdEq(owningReferencePropertyName,
primaryKey)).getSingleResult();
+ .add(AuditRestrictions.relatedIdEq(owningReferencePropertyName,
primaryKey)).getSingleResult();
} catch (NoResultException e) {
value = null;
} catch (NonUniqueResultException e) {
- throw new VersionsException("Many versions results for one-to-one
relationship: (" + owningEntityName +
+ throw new AuditException("Many versions results for one-to-one
relationship: (" + owningEntityName +
", " + owningReferencePropertyName + ")");
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ToOneIdMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ToOneIdMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/ToOneIdMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,12 +28,12 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
import org.hibernate.envers.entities.mapper.PropertyMapper;
import org.hibernate.envers.entities.mapper.id.IdMapper;
import
org.hibernate.envers.entities.mapper.relation.lazy.ToOneDelegateSessionImplementor;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.Tools;
import org.hibernate.envers.tools.reflection.ReflectionTools;
@@ -63,8 +63,8 @@
return !Tools.objectsEqual(newObj, oldObj);
}
- public void mapToEntityFromMap(VersionsConfiguration verCfg, Object obj, Map data,
Object primaryKey,
- VersionsReaderImplementor versionsReader, Number
revision) {
+ public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data,
Object primaryKey,
+ AuditReaderImplementor versionsReader, Number
revision) {
if (obj == null) {
return;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleMapKeyIdComponentMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleMapKeyIdComponentMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleMapKeyIdComponentMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -25,7 +25,7 @@
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.EntityInstantiator;
import org.hibernate.envers.entities.mapper.id.IdMapper;
import org.hibernate.envers.tools.query.Parameters;
@@ -37,10 +37,10 @@
* @author Adam Warski (adam at warski dot org)
*/
public final class MiddleMapKeyIdComponentMapper implements MiddleComponentMapper {
- private final VersionsEntitiesConfiguration verEntCfg;
+ private final AuditEntitiesConfiguration verEntCfg;
private final IdMapper relatedIdMapper;
- public MiddleMapKeyIdComponentMapper(VersionsEntitiesConfiguration verEntCfg,
IdMapper relatedIdMapper) {
+ public MiddleMapKeyIdComponentMapper(AuditEntitiesConfiguration verEntCfg, IdMapper
relatedIdMapper) {
this.verEntCfg = verEntCfg;
this.relatedIdMapper = relatedIdMapper;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleSimpleComponentMapper.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleSimpleComponentMapper.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/component/MiddleSimpleComponentMapper.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -25,7 +25,7 @@
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.EntityInstantiator;
import org.hibernate.envers.tools.query.Parameters;
@@ -34,9 +34,9 @@
*/
public final class MiddleSimpleComponentMapper implements MiddleComponentMapper {
private final String propertyName;
- private final VersionsEntitiesConfiguration verEntCfg;
+ private final AuditEntitiesConfiguration verEntCfg;
- public MiddleSimpleComponentMapper(VersionsEntitiesConfiguration verEntCfg, String
propertyName) {
+ public MiddleSimpleComponentMapper(AuditEntitiesConfiguration verEntCfg, String
propertyName) {
this.propertyName = propertyName;
this.verEntCfg = verEntCfg;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/ToOneDelegateSessionImplementor.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/ToOneDelegateSessionImplementor.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/ToOneDelegateSessionImplementor.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.entities.mapper.relation.lazy;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.HibernateException;
@@ -31,12 +31,12 @@
* @author Adam Warski (adam at warski dot org)
*/
public class ToOneDelegateSessionImplementor extends AbstractDelegateSessionImplementor
{
- private final VersionsReaderImplementor versionsReader;
+ private final AuditReaderImplementor versionsReader;
private final Class<?> entityClass;
private final Object entityId;
private final Number revision;
- public ToOneDelegateSessionImplementor(VersionsReaderImplementor versionsReader,
+ public ToOneDelegateSessionImplementor(AuditReaderImplementor versionsReader,
Class<?> entityClass, Object entityId,
Number revision) {
super(versionsReader.getSessionImplementor());
this.versionsReader = versionsReader;
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/AbstractCollectionInitializor.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/AbstractCollectionInitializor.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/AbstractCollectionInitializor.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -25,25 +25,25 @@
import java.util.List;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.EntityInstantiator;
import org.hibernate.envers.entities.mapper.relation.query.RelationQueryGenerator;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
/**
* Initializes a persistent collection.
* @author Adam Warski (adam at warski dot org)
*/
public abstract class AbstractCollectionInitializor<T> implements
Initializor<T> {
- private final VersionsReaderImplementor versionsReader;
+ private final AuditReaderImplementor versionsReader;
private final RelationQueryGenerator queryGenerator;
private final Object primaryKey;
protected final Number revision;
protected final EntityInstantiator entityInstantiator;
- public AbstractCollectionInitializor(VersionsConfiguration verCfg,
- VersionsReaderImplementor versionsReader,
+ public AbstractCollectionInitializor(AuditConfiguration verCfg,
+ AuditReaderImplementor versionsReader,
RelationQueryGenerator queryGenerator,
Object primaryKey, Number revision) {
this.versionsReader = versionsReader;
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ArrayCollectionInitializor.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ArrayCollectionInitializor.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ArrayCollectionInitializor.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,10 +26,10 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.query.RelationQueryGenerator;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
/**
* Initializes a map.
@@ -39,8 +39,8 @@
private final MiddleComponentData elementComponentData;
private final MiddleComponentData indexComponentData;
- public ArrayCollectionInitializor(VersionsConfiguration verCfg,
- VersionsReaderImplementor versionsReader,
+ public ArrayCollectionInitializor(AuditConfiguration verCfg,
+ AuditReaderImplementor versionsReader,
RelationQueryGenerator queryGenerator,
Object primaryKey, Number revision,
MiddleComponentData elementComponentData,
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,11 +27,11 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.query.RelationQueryGenerator;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.reader.AuditReaderImplementor;
/**
* Initializes a non-indexed java collection (set or list, eventually sorted).
@@ -41,8 +41,8 @@
private final Class<? extends T> collectionClass;
private final MiddleComponentData elementComponentData;
- public BasicCollectionInitializor(VersionsConfiguration verCfg,
- VersionsReaderImplementor versionsReader,
+ public BasicCollectionInitializor(AuditConfiguration verCfg,
+ AuditReaderImplementor versionsReader,
RelationQueryGenerator queryGenerator,
Object primaryKey, Number revision,
Class<? extends T> collectionClass,
@@ -57,9 +57,9 @@
try {
return collectionClass.newInstance();
} catch (InstantiationException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,10 +27,10 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.query.RelationQueryGenerator;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
/**
* Initializes a map.
@@ -40,8 +40,8 @@
private final MiddleComponentData elementComponentData;
private final MiddleComponentData indexComponentData;
- public ListCollectionInitializor(VersionsConfiguration verCfg,
- VersionsReaderImplementor versionsReader,
+ public ListCollectionInitializor(AuditConfiguration verCfg,
+ AuditReaderImplementor versionsReader,
RelationQueryGenerator queryGenerator,
Object primaryKey, Number revision,
MiddleComponentData elementComponentData,
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,11 +26,11 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.query.RelationQueryGenerator;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.reader.AuditReaderImplementor;
/**
* Initializes a map.
@@ -41,8 +41,8 @@
private final MiddleComponentData elementComponentData;
private final MiddleComponentData indexComponentData;
- public MapCollectionInitializor(VersionsConfiguration verCfg,
- VersionsReaderImplementor versionsReader,
+ public MapCollectionInitializor(AuditConfiguration verCfg,
+ AuditReaderImplementor versionsReader,
RelationQueryGenerator queryGenerator,
Object primaryKey, Number revision,
Class<? extends T> collectionClass,
@@ -59,9 +59,9 @@
try {
return collectionClass.newInstance();
} catch (InstantiationException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,11 +26,11 @@
import java.util.Collections;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.mapper.id.QueryParameterData;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.MiddleIdData;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.query.Parameters;
import org.hibernate.envers.tools.query.QueryBuilder;
@@ -44,7 +44,7 @@
private final String queryString;
private final MiddleIdData referencingIdData;
- public OneEntityQueryGenerator(VersionsEntitiesConfiguration verEntCfg,
+ public OneEntityQueryGenerator(AuditEntitiesConfiguration verEntCfg,
String versionsMiddleEntityName,
MiddleIdData referencingIdData,
MiddleComponentData... componentDatas) {
@@ -95,7 +95,7 @@
queryString = sb.toString();
}
- public Query getQuery(VersionsReaderImplementor versionsReader, Object primaryKey,
Number revision) {
+ public Query getQuery(AuditReaderImplementor versionsReader, Object primaryKey,
Number revision) {
Query query = versionsReader.getSession().createQuery(queryString);
query.setParameter("revision", revision);
query.setParameter("delrevisiontype", RevisionType.DEL);
Modified:
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/OneVersionsEntityQueryGenerator.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneVersionsEntityQueryGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,11 +27,11 @@
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.configuration.GlobalConfiguration;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+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.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.query.Parameters;
import org.hibernate.envers.tools.query.QueryBuilder;
@@ -45,7 +45,7 @@
private final String queryString;
private final MiddleIdData referencingIdData;
- public OneVersionsEntityQueryGenerator(GlobalConfiguration globalCfg,
VersionsEntitiesConfiguration verEntCfg,
+ public OneVersionsEntityQueryGenerator(GlobalConfiguration globalCfg,
AuditEntitiesConfiguration verEntCfg,
MiddleIdData referencingIdData, String
referencedEntityName,
IdMapper referencedIdMapper) {
this.referencingIdData = referencingIdData;
@@ -97,7 +97,7 @@
queryString = sb.toString();
}
- public Query getQuery(VersionsReaderImplementor versionsReader, Object primaryKey,
Number revision) {
+ public Query getQuery(AuditReaderImplementor versionsReader, Object primaryKey,
Number revision) {
Query query = versionsReader.getSession().createQuery(queryString);
query.setParameter("revision", revision);
query.setParameter("delrevisiontype", RevisionType.DEL);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/RelationQueryGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/RelationQueryGenerator.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/RelationQueryGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.entities.mapper.relation.query;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.Query;
@@ -34,5 +34,5 @@
* @author Adam Warski (adam at warski dot org)
*/
public interface RelationQueryGenerator {
- Query getQuery(VersionsReaderImplementor versionsReader, Object primaryKey, Number
revision);
+ Query getQuery(AuditReaderImplementor versionsReader, Object primaryKey, Number
revision);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/ThreeEntityQueryGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/ThreeEntityQueryGenerator.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/ThreeEntityQueryGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,11 +27,11 @@
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.configuration.GlobalConfiguration;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.mapper.id.QueryParameterData;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.MiddleIdData;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.query.Parameters;
import org.hibernate.envers.tools.query.QueryBuilder;
@@ -46,7 +46,7 @@
private final MiddleIdData referencingIdData;
public ThreeEntityQueryGenerator(GlobalConfiguration globalCfg,
- VersionsEntitiesConfiguration verEntCfg,
+ AuditEntitiesConfiguration verEntCfg,
String versionsMiddleEntityName,
MiddleIdData referencingIdData,
MiddleIdData referencedIdData,
@@ -123,7 +123,7 @@
queryString = sb.toString();
}
- public Query getQuery(VersionsReaderImplementor versionsReader, Object primaryKey,
Number revision) {
+ public Query getQuery(AuditReaderImplementor versionsReader, Object primaryKey,
Number revision) {
Query query = versionsReader.getSession().createQuery(queryString);
query.setParameter("revision", revision);
query.setParameter("delrevisiontype", RevisionType.DEL);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityQueryGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityQueryGenerator.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityQueryGenerator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,11 +27,11 @@
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.configuration.GlobalConfiguration;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.mapper.id.QueryParameterData;
import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
import org.hibernate.envers.entities.mapper.relation.MiddleIdData;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.query.Parameters;
import org.hibernate.envers.tools.query.QueryBuilder;
@@ -46,7 +46,7 @@
private final MiddleIdData referencingIdData;
public TwoEntityQueryGenerator(GlobalConfiguration globalCfg,
- VersionsEntitiesConfiguration verEntCfg,
+ AuditEntitiesConfiguration verEntCfg,
String versionsMiddleEntityName,
MiddleIdData referencingIdData,
MiddleIdData referencedIdData,
@@ -106,7 +106,7 @@
queryString = sb.toString();
}
- public Query getQuery(VersionsReaderImplementor versionsReader, Object primaryKey,
Number revision) {
+ public Query getQuery(AuditReaderImplementor versionsReader, Object primaryKey,
Number revision) {
Query query = versionsReader.getSession().createQuery(queryString);
query.setParameter("revision", revision);
query.setParameter("delrevisiontype", RevisionType.DEL);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/event/VersionsEventListener.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/event/VersionsEventListener.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/event/VersionsEventListener.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -25,12 +25,12 @@
import java.io.Serializable;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.RelationDescription;
import org.hibernate.envers.entities.RelationType;
import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
import org.hibernate.envers.entities.mapper.id.IdMapper;
-import org.hibernate.envers.synchronization.VersionsSync;
+import org.hibernate.envers.synchronization.AuditSync;
import org.hibernate.envers.synchronization.work.AddWorkUnit;
import org.hibernate.envers.synchronization.work.CollectionChangeWorkUnit;
import org.hibernate.envers.synchronization.work.DelWorkUnit;
@@ -63,9 +63,9 @@
public class VersionsEventListener implements PostInsertEventListener,
PostUpdateEventListener,
PostDeleteEventListener, PreCollectionUpdateEventListener,
PreCollectionRemoveEventListener,
PostCollectionRecreateEventListener, Initializable {
- private VersionsConfiguration verCfg;
+ private AuditConfiguration verCfg;
- private void generateBidirectionalCollectionChangeWorkUnits(VersionsSync verSync,
EntityPersister entityPersister,
+ private void generateBidirectionalCollectionChangeWorkUnits(AuditSync verSync,
EntityPersister entityPersister,
String entityName,
Object[] newState, Object[] oldState) {
// Checking if this is enabled in configuration ...
if (!verCfg.getGlobalCfg().isGenerateRevisionsForCollections()) {
@@ -108,7 +108,7 @@
String entityName = event.getPersister().getEntityName();
if (verCfg.getEntCfg().isVersioned(entityName)) {
- VersionsSync verSync = verCfg.getSyncManager().get(event.getSession());
+ AuditSync verSync = verCfg.getSyncManager().get(event.getSession());
verSync.addWorkUnit(new AddWorkUnit(event.getPersister().getEntityName(),
verCfg, event.getId(),
event.getPersister(), event.getState()));
@@ -121,7 +121,7 @@
String entityName = event.getPersister().getEntityName();
if (verCfg.getEntCfg().isVersioned(entityName)) {
- VersionsSync verSync = verCfg.getSyncManager().get(event.getSession());
+ AuditSync verSync = verCfg.getSyncManager().get(event.getSession());
verSync.addWorkUnit(new ModWorkUnit(event.getPersister().getEntityName(),
verCfg, event.getId(),
event.getPersister(), event.getState(), event.getOldState()));
@@ -134,7 +134,7 @@
String entityName = event.getPersister().getEntityName();
if (verCfg.getEntCfg().isVersioned(entityName)) {
- VersionsSync verSync = verCfg.getSyncManager().get(event.getSession());
+ AuditSync verSync = verCfg.getSyncManager().get(event.getSession());
verSync.addWorkUnit(new DelWorkUnit(event.getPersister().getEntityName(),
verCfg, event.getId()));
@@ -142,7 +142,7 @@
}
}
- private void generateBidirectionalCollectionChangeWorkUnits(VersionsSync verSync,
AbstractCollectionEvent event,
+ private void generateBidirectionalCollectionChangeWorkUnits(AuditSync verSync,
AbstractCollectionEvent event,
PersistentCollectionChangeWorkUnit workUnit) {
// Checking if this is enabled in configuration ...
if (!verCfg.getGlobalCfg().isGenerateRevisionsForCollections()) {
@@ -173,7 +173,7 @@
String entityName = event.getAffectedOwnerEntityName();
if (verCfg.getEntCfg().isVersioned(entityName)) {
- VersionsSync verSync = verCfg.getSyncManager().get(event.getSession());
+ AuditSync verSync = verCfg.getSyncManager().get(event.getSession());
PersistentCollectionChangeWorkUnit workUnit = new
PersistentCollectionChangeWorkUnit(entityName, verCfg,
newColl, collectionEntry.getRole(), oldColl,
event.getAffectedOwnerIdOrNull());
@@ -209,10 +209,10 @@
@SuppressWarnings({"unchecked"})
public void initialize(Configuration cfg) {
- verCfg = VersionsConfiguration.getFor(cfg);
+ verCfg = AuditConfiguration.getFor(cfg);
}
- public VersionsConfiguration getVerCfg() {
+ public AuditConfiguration getVerCfg() {
return verCfg;
}
}
Copied: core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/exception/VersionsException.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/exception/AuditException.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -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.exception;
+
+import org.hibernate.HibernateException;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditException extends HibernateException {
+ public AuditException(String message) {
+ super(message);
+ }
+
+ public AuditException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AuditException(Throwable cause) {
+ super(cause);
+ }
+}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotVersionedException.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotVersionedException.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/exception/NotVersionedException.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,7 +26,7 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class NotVersionedException extends VersionsException {
+public class NotVersionedException extends AuditException {
private final String entityName;
public NotVersionedException(String entityName, String message) {
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/exception/RevisionDoesNotExistException.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class RevisionDoesNotExistException extends VersionsException {
+public class RevisionDoesNotExistException extends AuditException {
private Number revision;
private Date date;
Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQuery.java (from
rev 15455, core/trunk/envers/src/main/java/org/hibernate/envers/query/VersionsQuery.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQuery.java
(rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+import java.util.List;
+import javax.persistence.NoResultException;
+import javax.persistence.NonUniqueResultException;
+
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.query.criteria.AuditCriterion;
+import org.hibernate.envers.query.order.AuditOrder;
+import org.hibernate.envers.query.projection.AuditProjection;
+
+import org.hibernate.CacheMode;
+import org.hibernate.FlushMode;
+import org.hibernate.LockMode;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ * @see org.hibernate.Criteria
+ */
+public interface AuditQuery {
+ List getResultList() throws AuditException;
+
+ Object getSingleResult() throws AuditException, NonUniqueResultException,
NoResultException;
+
+ AuditQuery add(AuditCriterion criterion);
+
+ AuditQuery addProjection(String function, String propertyName);
+
+ AuditQuery addProjection(AuditProjection projection);
+
+ AuditQuery addOrder(String propertyName, boolean asc);
+
+ AuditQuery addOrder(AuditOrder order);
+
+ AuditQuery setMaxResults(int maxResults);
+
+ AuditQuery setFirstResult(int firstResult);
+
+ AuditQuery setCacheable(boolean cacheable);
+
+ AuditQuery setCacheRegion(String cacheRegion);
+
+ AuditQuery setComment(String comment);
+
+ AuditQuery setFlushMode(FlushMode flushMode);
+
+ AuditQuery setCacheMode(CacheMode cacheMode);
+
+ AuditQuery setTimeout(int timeout);
+
+ AuditQuery setLockMode(LockMode lockMode);
+}
Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQueryCreator.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/query/VersionsQueryCreator.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQueryCreator.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQueryCreator.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.query.impl.EntitiesAtRevisionQuery;
+import org.hibernate.envers.query.impl.RevisionsOfEntityQuery;
+import org.hibernate.envers.reader.AuditReaderImplementor;
+import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull;
+import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditQueryCreator {
+ private final AuditConfiguration verCfg;
+ private final AuditReaderImplementor versionsReaderImplementor;
+
+ public AuditQueryCreator(AuditConfiguration verCfg, AuditReaderImplementor
versionsReaderImplementor) {
+ this.verCfg = verCfg;
+ this.versionsReaderImplementor = versionsReaderImplementor;
+ }
+
+ /**
+ * Creates a query, which will return entities satisfying some conditions (specified
later),
+ * at a given revision.
+ * @param c Class of the entities for which to query.
+ * @param revision Revision number at which to execute the query.
+ * @return A query for entities at a given revision, to which conditions can be added
and which
+ * can then be executed. The result of the query will be a list of entities (beans),
unless a
+ * projection is added.
+ */
+ public AuditQuery forEntitiesAtRevision(Class<?> c, Number revision) {
+ checkNotNull(revision, "Entity revision");
+ checkPositive(revision, "Entity revision");
+ return new EntitiesAtRevisionQuery(verCfg, versionsReaderImplementor, c,
revision);
+ }
+
+ /**
+ * Creates a query, which selects the revisions, at which the given entity was
modified.
+ * Unless an explicit projection is set, the result will be a list of three-element
arrays, containing:
+ * <ol>
+ * <li>the entity instance</li>
+ * <li>revision entity, corresponding to the revision at which the entity was
modified. If no custom
+ * revision entity is used, this will be an instance of {@link
org.hibernate.envers.DefaultRevisionEntity}</li>
+ * <li>type of the revision (an enum instance of class {@link
org.hibernate.envers.RevisionType})</li>.
+ * </ol>
+ * Additional conditions that the results must satisfy may be specified.
+ * @param c Class of the entities for which to query.
+ * @param selectEntitiesOnly If true, instead of a list of three-element arrays, a
list of entites will be
+ * returned as a result of executing this query.
+ * @param selectDeletedEntities If true, also revisions where entities were deleted
will be returned. The additional
+ * entities will have revision type "delete", and contain no data (all
fields null), except for the id field.
+ * @return A query for revisions at which instances of the given entity were
modified, to which
+ * conditions can be added (for example - a specific id of an entity of class
<code>c</code>), and which
+ * can then be executed. The results of the query will be sorted in ascending order
by the revision number,
+ * unless an order or projection is added.
+ */
+ public AuditQuery forRevisionsOfEntity(Class<?> c, boolean selectEntitiesOnly,
boolean selectDeletedEntities) {
+ return new RevisionsOfEntityQuery(verCfg, versionsReaderImplementor, c,
selectEntitiesOnly,selectDeletedEntities);
+ }
+}
Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/query/VersionsRestrictions.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,246 @@
+/*
+ * 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;
+
+import java.util.Collection;
+
+import org.hibernate.envers.query.criteria.AuditCriterion;
+import org.hibernate.envers.query.criteria.*;
+
+import org.hibernate.criterion.MatchMode;
+
+/**
+ * TODO: ilike
+ * @author Adam Warski (adam at warski dot org)
+ * @see org.hibernate.criterion.Restrictions
+ */
+@SuppressWarnings({"JavaDoc"})
+public class AuditRestrictions {
+ private AuditRestrictions() { }
+
+ /**
+ * Apply an "equal" constraint to the identifier property.
+ */
+ public static AuditCriterion idEq(Object value) {
+ return new IdentifierEqVersionsExpression(value);
+ }
+
+ /**
+ * Apply an "equal" constraint to the named property
+ */
+ public static AuditCriterion eq(String propertyName, Object value) {
+ return new SimpleVersionsExpression(propertyName, value, "=");
+ }
+
+ /**
+ * Apply a "not equal" constraint to the named property
+ */
+ public static AuditCriterion ne(String propertyName, Object value) {
+ return new SimpleVersionsExpression(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);
+ }
+
+ /**
+ * Apply a "not equal" constraint to the named property
+ */
+ public static AuditCriterion relatedIdNe(String propertyName, Object id) {
+ return new RelatedVersionsExpression(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 ");
+ }
+
+ /**
+ * 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 " );
+ }
+
+ /**
+ * Apply a "greater than" constraint to the named property
+ */
+ public static AuditCriterion gt(String propertyName, Object value) {
+ return new SimpleVersionsExpression(propertyName, value, ">");
+ }
+
+ /**
+ * Apply a "less than" constraint to the named property
+ */
+ public static AuditCriterion lt(String propertyName, Object value) {
+ return new SimpleVersionsExpression(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, "<=");
+ }
+
+ /**
+ * Apply a "greater than or equal" constraint to the named property
+ */
+ public static AuditCriterion ge(String propertyName, Object value) {
+ return new SimpleVersionsExpression(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);
+ }
+
+ /**
+ * Apply an "in" constraint to the named property
+ */
+ public static AuditCriterion in(String propertyName, Object[] values) {
+ return new InVersionsExpression(propertyName, values);
+ }
+
+ /**
+ * Apply an "in" constraint to the named property
+ */
+ public static AuditCriterion in(String propertyName, Collection values) {
+ return new InVersionsExpression(propertyName, values.toArray());
+ }
+
+ /**
+ * Apply an "is null" constraint to the named property
+ */
+ public static AuditCriterion isNull(String propertyName) {
+ return new NullVersionsExpression(propertyName);
+ }
+
+ /**
+ * Apply an "equal" constraint to two properties
+ */
+ public static AuditCriterion eqProperty(String propertyName, String otherPropertyName)
{
+ return new PropertyVersionsExpression(propertyName, otherPropertyName, "=");
+ }
+
+ /**
+ * Apply a "not equal" constraint to two properties
+ */
+ public static AuditCriterion neProperty(String propertyName, String otherPropertyName)
{
+ return new PropertyVersionsExpression(propertyName, otherPropertyName,
"<>");
+ }
+
+ /**
+ * Apply a "less than" constraint to two properties
+ */
+ public static AuditCriterion ltProperty(String propertyName, String otherPropertyName)
{
+ return new PropertyVersionsExpression(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,
"<=");
+ }
+
+ /**
+ * Apply a "greater than" constraint to two properties
+ */
+ public static AuditCriterion gtProperty(String propertyName, String otherPropertyName)
{
+ return new PropertyVersionsExpression(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,
">=");
+ }
+
+ /**
+ * Apply an "is not null" constraint to the named property
+ */
+ public static AuditCriterion isNotNull(String propertyName) {
+ return new NotNullVersionsExpression(propertyName);
+ }
+
+ /**
+ * Return the conjuction of two expressions
+ */
+ public static AuditCriterion and(AuditCriterion lhs, AuditCriterion rhs) {
+ return new LogicalVersionsExpression(lhs, rhs, "and");
+ }
+
+ /**
+ * Return the disjuction of two expressions
+ */
+ public static AuditCriterion or(AuditCriterion lhs, AuditCriterion rhs) {
+ return new LogicalVersionsExpression(lhs, rhs, "or");
+ }
+
+ /**
+ * Return the negation of an expression
+ */
+ public static AuditCriterion not(AuditCriterion expression) {
+ return new NotVersionsExpression(expression);
+ }
+
+ /**
+ * Group expressions together in a single conjunction (A and B and C...)
+ */
+ public static AuditConjunction conjunction() {
+ return new AuditConjunction();
+ }
+
+ /**
+ * Group expressions together in a single disjunction (A or B or C...)
+ */
+ public static AuditDisjunction disjunction() {
+ return new AuditDisjunction();
+ }
+
+ /**
+ * Apply a "maximalize property" constraint.
+ */
+ public static AggregatedFieldVersionsExpression maximizeProperty(String propertyName)
{
+ return new AggregatedFieldVersionsExpression(propertyName,
+ AggregatedFieldVersionsExpression.AggregatedMode.MAX);
+ }
+
+ /**
+ * Apply a "minimize property" constraint.
+ */
+ public static AggregatedFieldVersionsExpression minimizeProperty(String propertyName)
{
+ return new AggregatedFieldVersionsExpression(propertyName,
+ AggregatedFieldVersionsExpression.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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,107 +23,107 @@
*/
package org.hibernate.envers.query;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.query.criteria.RevisionVersionsExpression;
-import org.hibernate.envers.query.criteria.VersionsCriterion;
+import org.hibernate.envers.query.criteria.AuditCriterion;
import org.hibernate.envers.query.order.RevisionVersionsOrder;
-import org.hibernate.envers.query.order.VersionsOrder;
+import org.hibernate.envers.query.order.AuditOrder;
import org.hibernate.envers.query.projection.RevisionVersionsProjection;
-import org.hibernate.envers.query.projection.VersionsProjection;
+import org.hibernate.envers.query.projection.AuditProjection;
import org.hibernate.envers.tools.Triple;
/**
* @author Adam Warski (adam at warski dot org)
*/
@SuppressWarnings({"JavaDoc"})
-public class RevisionProperty implements VersionsProjection {
+public class RevisionProperty implements AuditProjection {
private RevisionProperty() { }
/**
* Apply a "greater than" constraint on the revision number
*/
- public static VersionsCriterion gt(Integer revision) {
+ public static AuditCriterion gt(Integer revision) {
return new RevisionVersionsExpression(revision, ">");
}
/**
* Apply a "greater than or equal" constraint on the revision number
*/
- public static VersionsCriterion ge(Integer revision) {
+ public static AuditCriterion ge(Integer revision) {
return new RevisionVersionsExpression(revision, ">=");
}
/**
* Apply a "less than" constraint on the revision number
*/
- public static VersionsCriterion lt(Integer revision) {
+ public static AuditCriterion lt(Integer revision) {
return new RevisionVersionsExpression(revision, "<");
}
/**
* Apply a "less than or equal" constraint on the revision number
*/
- public static VersionsCriterion le(Integer revision) {
+ public static AuditCriterion le(Integer revision) {
return new RevisionVersionsExpression(revision, "<=");
}
/**
* Sort the results by revision in ascending order
*/
- public static VersionsOrder asc() {
+ public static AuditOrder asc() {
return new RevisionVersionsOrder(true);
}
/**
* Sort the results by revision in descending order
*/
- public static VersionsOrder desc() {
+ public static AuditOrder desc() {
return new RevisionVersionsOrder(false);
}
/**
* Select the maximum revision
*/
- public static VersionsProjection max() {
+ public static AuditProjection max() {
return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.MAX);
}
/**
* Select the minimum revision
*/
- public static VersionsProjection min() {
+ public static AuditProjection min() {
return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.MIN);
}
/**
* Count revisions
*/
- public static VersionsProjection count() {
+ public static AuditProjection count() {
return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.COUNT);
}
/**
* Count distinct revisions
*/
- public static VersionsProjection countDistinct() {
+ public static AuditProjection countDistinct() {
return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.COUNT_DISTINCT);
}
/**
* Distinct revisions
*/
- public static VersionsProjection distinct() {
+ public static AuditProjection distinct() {
return new
RevisionVersionsProjection(RevisionVersionsProjection.ProjectionType.DISTINCT);
}
/**
* Projection the revision number
*/
- public static VersionsProjection revisionNumber() {
+ public static AuditProjection revisionNumber() {
return new RevisionProperty();
}
- public Triple<String, String, Boolean> getData(VersionsConfiguration verCfg) {
+ public Triple<String, String, Boolean> getData(AuditConfiguration verCfg) {
return Triple.make(null, verCfg.getVerEntCfg().getRevisionPropPath(), false);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionTypeProperty.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionTypeProperty.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionTypeProperty.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,25 +23,25 @@
*/
package org.hibernate.envers.query;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.query.projection.VersionsProjection;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.query.projection.AuditProjection;
import org.hibernate.envers.tools.Triple;
/**
* @author Adam Warski (adam at warski dot org)
*/
@SuppressWarnings({"JavaDoc"})
-public class RevisionTypeProperty implements VersionsProjection {
+public class RevisionTypeProperty implements AuditProjection {
private RevisionTypeProperty() { }
/**
* Projection on the revision type
*/
- public static VersionsProjection revisionType() {
+ public static AuditProjection revisionType() {
return new RevisionTypeProperty();
}
- public Triple<String, String, Boolean> getData(VersionsConfiguration verCfg) {
+ public Triple<String, String, Boolean> getData(AuditConfiguration verCfg) {
return Triple.make(null, verCfg.getVerEntCfg().getRevisionTypePropName(),
false);
}
}
\ No newline at end of file
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,14 +26,14 @@
import java.util.ArrayList;
import java.util.List;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 AggregatedFieldVersionsExpression implements VersionsCriterion,
ExtendableCriterion {
+public class AggregatedFieldVersionsExpression implements AuditCriterion,
ExtendableCriterion {
public static enum AggregatedMode {
MAX,
MIN
@@ -41,20 +41,20 @@
private String propertyName;
private AggregatedMode mode;
- private List<VersionsCriterion> criterions;
+ private List<AuditCriterion> criterions;
public AggregatedFieldVersionsExpression(String propertyName, AggregatedMode mode) {
this.propertyName = propertyName;
this.mode = mode;
- criterions = new ArrayList<VersionsCriterion>();
+ criterions = new ArrayList<AuditCriterion>();
}
- public AggregatedFieldVersionsExpression add(VersionsCriterion criterion) {
+ public AggregatedFieldVersionsExpression add(AuditCriterion criterion) {
criterions.add(criterion);
return this;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ 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
@@ -62,7 +62,7 @@
// Adding all specified conditions both to the main query, as well as to the
// aggregated one.
- for (VersionsCriterion versionsCriteria : criterions) {
+ for (AuditCriterion versionsCriteria : criterions) {
versionsCriteria.addToQuery(verCfg, entityName, qb, parameters);
versionsCriteria.addToQuery(verCfg, entityName, subQb,
subQb.getRootParameters());
}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditConjunction.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/VersionsConjunction.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditConjunction.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditConjunction.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,55 @@
+/*
+ * 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 AuditConjunction implements AuditCriterion, ExtendableCriterion {
+ private List<AuditCriterion> criterions;
+
+ public AuditConjunction() {
+ criterions = new ArrayList<AuditCriterion>();
+ }
+
+ public AuditConjunction add(AuditCriterion criterion) {
+ criterions.add(criterion);
+ return this;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ Parameters andParameters = parameters.addSubParameters(Parameters.AND);
+
+ for (AuditCriterion criterion : criterions) {
+ criterion.addToQuery(verCfg, entityName, qb, andParameters);
+ }
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditCriterion.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/VersionsCriterion.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditCriterion.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditCriterion.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,35 @@
+/*
+ * 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 interface AuditCriterion {
+ void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters);
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditDisjunction.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/VersionsDisjunction.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditDisjunction.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditDisjunction.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,55 @@
+/*
+ * 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 AuditDisjunction implements AuditCriterion, ExtendableCriterion {
+ private List<AuditCriterion> criterions;
+
+ public AuditDisjunction() {
+ criterions = new ArrayList<AuditCriterion>();
+ }
+
+ public AuditDisjunction add(AuditCriterion criterion) {
+ criterions.add(criterion);
+ return this;
+ }
+
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
+ Parameters orParameters = parameters.addSubParameters(Parameters.OR);
+
+ for (AuditCriterion criterion : criterions) {
+ criterion.addToQuery(verCfg, entityName, qb, orParameters);
+ }
+ }
+}
\ No newline at end of file
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,14 +23,14 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 BetweenVersionsExpression implements VersionsCriterion {
+public class BetweenVersionsExpression implements AuditCriterion {
private String propertyName;
private Object lo;
private Object hi;
@@ -41,7 +41,7 @@
this.hi = hi;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
parameters.addWhereWithParam(propertyName, ">=", lo);
parameters.addWhereWithParam(propertyName, "<=", hi);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/CriteriaTools.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/CriteriaTools.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/CriteriaTools.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,10 +23,10 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.RelationDescription;
import org.hibernate.envers.entities.RelationType;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* @author Adam Warski (adam at warski dot org)
@@ -34,16 +34,16 @@
public class CriteriaTools {
private CriteriaTools() { }
- public static void checkPropertyNotARelation(VersionsConfiguration verCfg, String
entityName,
- String propertyName) throws
VersionsException {
+ public static void checkPropertyNotARelation(AuditConfiguration verCfg, String
entityName,
+ String propertyName) throws
AuditException {
if (verCfg.getEntCfg().get(entityName).isRelation(propertyName)) {
- throw new VersionsException("This criterion cannot be used on a property
that is " +
+ throw new AuditException("This criterion cannot be used on a property
that is " +
"a relation to another property.");
}
}
- public static RelationDescription getRelatedEntity(VersionsConfiguration verCfg,
String entityName,
- String propertyName) throws
VersionsException {
+ public static RelationDescription getRelatedEntity(AuditConfiguration verCfg, String
entityName,
+ String propertyName) throws
AuditException {
RelationDescription relationDesc =
verCfg.getEntCfg().getRelationDescription(entityName, propertyName);
if (relationDesc == null) {
@@ -54,7 +54,7 @@
return relationDesc;
}
- throw new VersionsException("This type of relation (" + entityName +
"." + propertyName +
+ throw new AuditException("This type of relation (" + entityName +
"." + propertyName +
") isn't supported and can't be used in queries.");
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/ExtendableCriterion.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/ExtendableCriterion.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/ExtendableCriterion.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,5 +27,5 @@
* @author Adam Warski (adam at warski dot org)
*/
public interface ExtendableCriterion {
- public ExtendableCriterion add(VersionsCriterion criterion);
+ public ExtendableCriterion add(AuditCriterion criterion);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,21 +23,21 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 IdentifierEqVersionsExpression implements VersionsCriterion {
+public class IdentifierEqVersionsExpression implements AuditCriterion {
private Object id;
public IdentifierEqVersionsExpression(Object id) {
this.id = id;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
verCfg.getEntCfg().get(entityName).getIdMapper()
.addIdEqualsToQuery(parameters, id,
verCfg.getVerEntCfg().getOriginalIdPropName(), true);
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,14 +23,14 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 InVersionsExpression implements VersionsCriterion {
+public class InVersionsExpression implements AuditCriterion {
private String propertyName;
private Object[] values;
@@ -39,7 +39,7 @@
this.values = values;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
parameters.addWhereWithParams(propertyName, "in (", values,
")");
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/LogicalVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,25 +23,25 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 LogicalVersionsExpression implements VersionsCriterion {
- private VersionsCriterion lhs;
- private VersionsCriterion rhs;
+public class LogicalVersionsExpression implements AuditCriterion {
+ private AuditCriterion lhs;
+ private AuditCriterion rhs;
private String op;
- public LogicalVersionsExpression(VersionsCriterion lhs, VersionsCriterion rhs, String
op) {
+ public LogicalVersionsExpression(AuditCriterion lhs, AuditCriterion rhs, String op)
{
this.lhs = lhs;
this.rhs = rhs;
this.op = op;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
Parameters opParameters = parameters.addSubParameters(op);
lhs.addToQuery(verCfg, entityName, qb,
opParameters.addSubParameters("and"));
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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;
@@ -31,14 +31,14 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class NotNullVersionsExpression implements VersionsCriterion {
+public class NotNullVersionsExpression implements AuditCriterion {
private String propertyName;
public NotNullVersionsExpression(String propertyName) {
this.propertyName = propertyName;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg,
entityName, propertyName);
if (relatedEntity == null) {
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,21 +23,21 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 NotVersionsExpression implements VersionsCriterion {
- private VersionsCriterion criterion;
+public class NotVersionsExpression implements AuditCriterion {
+ private AuditCriterion criterion;
- public NotVersionsExpression(VersionsCriterion criterion) {
+ public NotVersionsExpression(AuditCriterion criterion) {
this.criterion = criterion;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
criterion.addToQuery(verCfg, entityName, qb, parameters.addNegatedParameters());
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,7 +23,7 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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;
@@ -31,14 +31,14 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class NullVersionsExpression implements VersionsCriterion {
+public class NullVersionsExpression implements AuditCriterion {
private String propertyName;
public NullVersionsExpression(String propertyName) {
this.propertyName = propertyName;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg,
entityName, propertyName);
if (relatedEntity == null) {
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,14 +23,14 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 PropertyVersionsExpression implements VersionsCriterion {
+public class PropertyVersionsExpression implements AuditCriterion {
private String propertyName;
private String otherPropertyName;
private String op;
@@ -41,7 +41,7 @@
this.op = op;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ 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);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,16 +23,16 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.RelationDescription;
-import org.hibernate.envers.exception.VersionsException;
+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 RelatedVersionsExpression implements VersionsCriterion {
+public class RelatedVersionsExpression implements AuditCriterion {
private String propertyName;
private Object id;
private boolean equals;
@@ -43,11 +43,11 @@
this.equals = equals;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg,
entityName, propertyName);
if (relatedEntity == null) {
- throw new VersionsException("This criterion can only be used on a
property that is " +
+ 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);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,14 +23,14 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+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 RevisionVersionsExpression implements VersionsCriterion {
+public class RevisionVersionsExpression implements AuditCriterion {
private Object value;
private String op;
@@ -39,7 +39,7 @@
this.op = op;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb,
Parameters parameters) {
parameters.addWhereWithParam(verCfg.getVerEntCfg().getRevisionPropPath(), op,
value);
}
}
\ No newline at end of file
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleVersionsExpression.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleVersionsExpression.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleVersionsExpression.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,16 +23,16 @@
*/
package org.hibernate.envers.query.criteria;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.RelationDescription;
-import org.hibernate.envers.exception.VersionsException;
+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 SimpleVersionsExpression implements VersionsCriterion {
+public class SimpleVersionsExpression implements AuditCriterion {
private String propertyName;
private Object value;
private String op;
@@ -43,14 +43,14 @@
this.op = op;
}
- public void addToQuery(VersionsConfiguration verCfg, String entityName, QueryBuilder
qb, Parameters parameters) {
+ 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 VersionsException("This type of operation: " + op +
" (" + entityName + "." + propertyName +
+ throw new AuditException("This type of operation: " + op +
" (" + entityName + "." + propertyName +
") isn't supported and can't be used in
queries.");
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractVersionsQuery.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractVersionsQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractVersionsQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -30,14 +30,14 @@
import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.entities.EntityInstantiator;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.query.VersionsQuery;
-import org.hibernate.envers.query.criteria.VersionsCriterion;
-import org.hibernate.envers.query.order.VersionsOrder;
-import org.hibernate.envers.query.projection.VersionsProjection;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.query.AuditQuery;
+import org.hibernate.envers.query.criteria.AuditCriterion;
+import org.hibernate.envers.query.order.AuditOrder;
+import org.hibernate.envers.query.projection.AuditProjection;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.Pair;
import org.hibernate.envers.tools.Triple;
import org.hibernate.envers.tools.query.QueryBuilder;
@@ -50,9 +50,9 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public abstract class AbstractVersionsQuery implements VersionsQuery {
+public abstract class AbstractVersionsQuery implements AuditQuery {
protected EntityInstantiator entityInstantiator;
- protected List<VersionsCriterion> criterions;
+ protected List<AuditCriterion> criterions;
protected String entityName;
protected String versionsEntityName;
@@ -61,15 +61,15 @@
protected boolean hasProjection;
protected boolean hasOrder;
- protected final VersionsConfiguration verCfg;
- private final VersionsReaderImplementor versionsReader;
+ protected final AuditConfiguration verCfg;
+ private final AuditReaderImplementor versionsReader;
- protected AbstractVersionsQuery(VersionsConfiguration verCfg,
VersionsReaderImplementor versionsReader,
+ protected AbstractVersionsQuery(AuditConfiguration verCfg, AuditReaderImplementor
versionsReader,
Class<?> cls) {
this.verCfg = verCfg;
this.versionsReader = versionsReader;
- criterions = new ArrayList<VersionsCriterion>();
+ criterions = new ArrayList<AuditCriterion>();
entityInstantiator = new EntityInstantiator(verCfg, versionsReader);
entityName = cls.getName();
@@ -94,13 +94,13 @@
return query.list();
}
- public abstract List list() throws VersionsException;
+ public abstract List list() throws AuditException;
- public List getResultList() throws VersionsException {
+ public List getResultList() throws AuditException {
return list();
}
- public Object getSingleResult() throws VersionsException, NonUniqueResultException,
NoResultException {
+ public Object getSingleResult() throws AuditException, NonUniqueResultException,
NoResultException {
List result = list();
if (result == null || result.size() == 0) {
@@ -114,33 +114,33 @@
return result.get(0);
}
- public VersionsQuery add(VersionsCriterion criterion) {
+ public AuditQuery add(AuditCriterion criterion) {
criterions.add(criterion);
return this;
}
// Projection and order
- public VersionsQuery addProjection(String function, String propertyName) {
+ public AuditQuery addProjection(String function, String propertyName) {
hasProjection = true;
qb.addProjection(function, propertyName, false);
return this;
}
- public VersionsQuery addProjection(VersionsProjection projection) {
+ public AuditQuery addProjection(AuditProjection projection) {
Triple<String, String, Boolean> projectionData =
projection.getData(verCfg);
hasProjection = true;
qb.addProjection(projectionData.getFirst(), projectionData.getSecond(),
projectionData.getThird());
return this;
}
- public VersionsQuery addOrder(String propertyName, boolean asc) {
+ public AuditQuery addOrder(String propertyName, boolean asc) {
hasOrder = true;
qb.addOrder(propertyName, asc);
return this;
}
- public VersionsQuery addOrder(VersionsOrder order) {
+ public AuditQuery addOrder(AuditOrder order) {
Pair<String, Boolean> orderData = order.getData(verCfg);
return addOrder(orderData.getFirst(), orderData.getSecond());
}
@@ -157,47 +157,47 @@
private Integer timeout;
private LockMode lockMode;
- public VersionsQuery setMaxResults(int maxResults) {
+ public AuditQuery setMaxResults(int maxResults) {
this.maxResults = maxResults;
return this;
}
- public VersionsQuery setFirstResult(int firstResult) {
+ public AuditQuery setFirstResult(int firstResult) {
this.firstResult = firstResult;
return this;
}
- public VersionsQuery setCacheable(boolean cacheable) {
+ public AuditQuery setCacheable(boolean cacheable) {
this.cacheable = cacheable;
return this;
}
- public VersionsQuery setCacheRegion(String cacheRegion) {
+ public AuditQuery setCacheRegion(String cacheRegion) {
this.cacheRegion = cacheRegion;
return this;
}
- public VersionsQuery setComment(String comment) {
+ public AuditQuery setComment(String comment) {
this.comment = comment;
return this;
}
- public VersionsQuery setFlushMode(FlushMode flushMode) {
+ public AuditQuery setFlushMode(FlushMode flushMode) {
this.flushMode = flushMode;
return this;
}
- public VersionsQuery setCacheMode(CacheMode cacheMode) {
+ public AuditQuery setCacheMode(CacheMode cacheMode) {
this.cacheMode = cacheMode;
return this;
}
- public VersionsQuery setTimeout(int timeout) {
+ public AuditQuery setTimeout(int timeout) {
this.timeout = timeout;
return this;
}
- public VersionsQuery setLockMode(LockMode lockMode) {
+ public AuditQuery setLockMode(LockMode lockMode) {
this.lockMode = lockMode;
return this;
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/EntitiesAtRevisionQuery.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/EntitiesAtRevisionQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/EntitiesAtRevisionQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,10 +27,10 @@
import java.util.List;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
-import org.hibernate.envers.query.criteria.VersionsCriterion;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
+import org.hibernate.envers.query.criteria.AuditCriterion;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.envers.tools.query.QueryBuilder;
/**
@@ -39,8 +39,8 @@
public class EntitiesAtRevisionQuery extends AbstractVersionsQuery {
private final Number revision;
- public EntitiesAtRevisionQuery(VersionsConfiguration verCfg,
- VersionsReaderImplementor versionsReader,
Class<?> cls,
+ public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
+ AuditReaderImplementor versionsReader, Class<?>
cls,
Number revision) {
super(verCfg, versionsReader, cls);
this.revision = revision;
@@ -59,7 +59,7 @@
QueryBuilder maxRevQb = qb.newSubQueryBuilder(versionsEntityName,
"e2");
- VersionsEntitiesConfiguration verEntCfg = verCfg.getVerEntCfg();
+ AuditEntitiesConfiguration verEntCfg = verCfg.getVerEntCfg();
String revisionPropertyPath = verEntCfg.getRevisionPropPath();
String originalIdPropertyName = verEntCfg.getOriginalIdPropName();
@@ -77,7 +77,7 @@
// e.revision = (SELECT max(...) ...)
qb.getRootParameters().addWhere(revisionPropertyPath,
verCfg.getGlobalCfg().getCorrelatedSubqueryOperator(), maxRevQb);
// all specified conditions
- for (VersionsCriterion criterion : criterions) {
+ for (AuditCriterion criterion : criterions) {
criterion.addToQuery(verCfg, entityName, qb, qb.getRootParameters());
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/RevisionsOfEntityQuery.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/RevisionsOfEntityQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/RevisionsOfEntityQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,11 +28,11 @@
import java.util.Map;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
-import org.hibernate.envers.exception.VersionsException;
-import org.hibernate.envers.query.criteria.VersionsCriterion;
-import org.hibernate.envers.reader.VersionsReaderImplementor;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.query.criteria.AuditCriterion;
+import org.hibernate.envers.reader.AuditReaderImplementor;
import org.hibernate.proxy.HibernateProxy;
@@ -43,8 +43,8 @@
private final boolean selectEntitiesOnly;
private final boolean selectDeletedEntities;
- public RevisionsOfEntityQuery(VersionsConfiguration verCfg,
- VersionsReaderImplementor versionsReader,
+ public RevisionsOfEntityQuery(AuditConfiguration verCfg,
+ AuditReaderImplementor versionsReader,
Class<?> cls, boolean selectEntitiesOnly,
boolean selectDeletedEntities) {
super(verCfg, versionsReader, cls);
@@ -54,7 +54,7 @@
}
private Number getRevisionNumber(Map versionsEntity) {
- VersionsEntitiesConfiguration verEntCfg = verCfg.getVerEntCfg();
+ AuditEntitiesConfiguration verEntCfg = verCfg.getVerEntCfg();
String originalId = verEntCfg.getOriginalIdPropName();
String revisionPropertyName = verEntCfg.getRevisionPropName();
@@ -70,8 +70,8 @@
}
@SuppressWarnings({"unchecked"})
- public List list() throws VersionsException {
- VersionsEntitiesConfiguration verEntCfg = verCfg.getVerEntCfg();
+ public List list() throws AuditException {
+ AuditEntitiesConfiguration verEntCfg = verCfg.getVerEntCfg();
/*
The query that should be executed in the versions table:
@@ -87,7 +87,7 @@
}
// all specified conditions, transformed
- for (VersionsCriterion criterion : criterions) {
+ for (AuditCriterion criterion : criterions) {
criterion.addToQuery(verCfg, entityName, qb, qb.getRootParameters());
}
Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/order/AuditOrder.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/VersionsOrder.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/order/AuditOrder.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/AuditOrder.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,38 @@
+/*
+ * 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 interface AuditOrder {
+ /**
+ * @param verCfg Configuration.
+ * @return A pair: (property name, ascending?).
+ */
+ Pair<String, Boolean> getData(AuditConfiguration verCfg);
+}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionVersionsOrder.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionVersionsOrder.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionVersionsOrder.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,20 +23,20 @@
*/
package org.hibernate.envers.query.order;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.tools.Pair;
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class RevisionVersionsOrder implements VersionsOrder {
+public class RevisionVersionsOrder implements AuditOrder {
private final boolean asc;
public RevisionVersionsOrder(boolean asc) {
this.asc = asc;
}
- public Pair<String, Boolean> getData(VersionsConfiguration verCfg) {
+ public Pair<String, Boolean> getData(AuditConfiguration verCfg) {
String revisionPropPath = verCfg.getVerEntCfg().getRevisionPropPath();
return Pair.make(revisionPropPath, asc);
}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/AuditProjection.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/VersionsProjection.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/AuditProjection.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/AuditProjection.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,39 @@
+/*
+ * 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 interface AuditProjection {
+ /**
+ *
+ * @param verCfg Configuration.
+ * @return A triple: (function name - possibly null, property name, add distinct?).
+ */
+ Triple<String, String, Boolean> getData(AuditConfiguration verCfg);
+}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionVersionsProjection.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionVersionsProjection.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionVersionsProjection.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -23,13 +23,13 @@
*/
package org.hibernate.envers.query.projection;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.tools.Triple;
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class RevisionVersionsProjection implements VersionsProjection {
+public class RevisionVersionsProjection implements AuditProjection {
public static enum ProjectionType {
MAX,
MIN,
@@ -44,7 +44,7 @@
this.type = type;
}
- public Triple<String, String, Boolean> getData(VersionsConfiguration verCfg) {
+ public Triple<String, String, Boolean> getData(AuditConfiguration verCfg) {
String revisionPropPath = verCfg.getVerEntCfg().getRevisionPropPath();
switch (type) {
Copied: core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/reader/VersionsReaderImpl.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,197 @@
+/*
+ * 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.reader;
+
+import java.util.Date;
+import java.util.List;
+import javax.persistence.NoResultException;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.exception.NotVersionedException;
+import org.hibernate.envers.exception.RevisionDoesNotExistException;
+import org.hibernate.envers.exception.AuditException;
+import org.hibernate.envers.query.RevisionProperty;
+import org.hibernate.envers.query.AuditQueryCreator;
+import org.hibernate.envers.query.AuditRestrictions;
+import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull;
+import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
+
+import org.hibernate.NonUniqueResultException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionImplementor;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditReaderImpl implements AuditReaderImplementor {
+ private final AuditConfiguration verCfg;
+ private final SessionImplementor sessionImplementor;
+ private final Session session;
+ private final FirstLevelCache firstLevelCache;
+
+ public AuditReaderImpl(AuditConfiguration verCfg, Session session,
+ SessionImplementor sessionImplementor) {
+ this.verCfg = verCfg;
+ this.sessionImplementor = sessionImplementor;
+ this.session = session;
+
+ firstLevelCache = new FirstLevelCache();
+ }
+
+ private void checkSession() {
+ if (!session.isOpen()) {
+ throw new IllegalStateException("The associated entity manager is
closed!");
+ }
+ }
+
+ public SessionImplementor getSessionImplementor() {
+ return sessionImplementor;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public FirstLevelCache getFirstLevelCache() {
+ return firstLevelCache;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T> T find(Class<T> cls, Object primaryKey, Number revision)
throws
+ IllegalArgumentException, NotVersionedException, IllegalStateException {
+ checkNotNull(cls, "Entity class");
+ checkNotNull(primaryKey, "Primary key");
+ checkNotNull(revision, "Entity revision");
+ checkPositive(revision, "Entity revision");
+ checkSession();
+
+ String entityName = cls.getName();
+
+ if (!verCfg.getEntCfg().isVersioned(entityName)) {
+ throw new NotVersionedException(entityName, entityName + " is not
versioned!");
+ }
+
+ if (firstLevelCache.contains(entityName, revision, primaryKey)) {
+ return (T) firstLevelCache.get(entityName, revision, primaryKey);
+ }
+
+ Object result;
+ try {
+ // The result is put into the cache by the entity instantiator called from
the query
+ result = createQuery().forEntitiesAtRevision(cls, revision)
+ .add(AuditRestrictions.idEq(primaryKey)).getSingleResult();
+ } catch (NoResultException e) {
+ result = null;
+ } catch (NonUniqueResultException e) {
+ throw new AuditException(e);
+ }
+
+ return (T) result;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public List<Number> getRevisions(Class<?> cls, Object primaryKey)
+ throws IllegalArgumentException, NotVersionedException, IllegalStateException
{
+ // todo: if a class is not versioned from the beginning, there's a missing
ADD rev - what then?
+ checkNotNull(cls, "Entity class");
+ checkNotNull(primaryKey, "Primary key");
+ checkSession();
+
+ String entityName = cls.getName();
+
+ if (!verCfg.getEntCfg().isVersioned(entityName)) {
+ throw new NotVersionedException(entityName, entityName + " is not
versioned!");
+ }
+
+ return createQuery().forRevisionsOfEntity(cls, false, true)
+ .addProjection(RevisionProperty.revisionNumber())
+ .add(AuditRestrictions.idEq(primaryKey))
+ .getResultList();
+ }
+
+ public Date getRevisionDate(Number revision) throws IllegalArgumentException,
RevisionDoesNotExistException,
+ IllegalStateException{
+ checkNotNull(revision, "Entity revision");
+ checkPositive(revision, "Entity revision");
+ checkSession();
+
+ Query query = verCfg.getRevisionInfoQueryCreator().getRevisionDateQuery(session,
revision);
+
+ try {
+ Long timestamp = (Long) query.uniqueResult();
+ if (timestamp == null) {
+ throw new RevisionDoesNotExistException(revision);
+ }
+
+ return new Date(timestamp);
+ } catch (NonUniqueResultException e) {
+ throw new AuditException(e);
+ }
+ }
+
+ public Number getRevisionNumberForDate(Date date) {
+ checkNotNull(date, "Date of revision");
+ checkSession();
+
+ Query query =
verCfg.getRevisionInfoQueryCreator().getRevisionNumberForDateQuery(session, date);
+
+ try {
+ Number res = (Number) query.uniqueResult();
+ if (res == null) {
+ throw new RevisionDoesNotExistException(date);
+ }
+
+ return res;
+ } catch (NonUniqueResultException e) {
+ throw new AuditException(e);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T> T findRevision(Class<T> revisionEntityClass, Number revision)
throws IllegalArgumentException,
+ RevisionDoesNotExistException, IllegalStateException {
+ checkNotNull(revision, "Entity revision");
+ checkPositive(revision, "Entity revision");
+ checkSession();
+
+ Query query = verCfg.getRevisionInfoQueryCreator().getRevisionQuery(session,
revision);
+
+ try {
+ T revisionData = (T) query.uniqueResult();
+
+ if (revisionData == null) {
+ throw new RevisionDoesNotExistException(revision);
+ }
+
+ return revisionData;
+ } catch (NonUniqueResultException e) {
+ throw new AuditException(e);
+ }
+ }
+
+ public AuditQueryCreator createQuery() {
+ return new AuditQueryCreator(verCfg, this);
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java
(from rev 15459,
core/trunk/envers/src/main/java/org/hibernate/envers/reader/VersionsReaderImplementor.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImplementor.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,39 @@
+/*
+ * 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.reader;
+
+import org.hibernate.envers.AuditReader;
+
+import org.hibernate.Session;
+import org.hibernate.engine.SessionImplementor;
+
+/**
+ * An interface exposed by a VersionsReader to library-facing classes.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public interface AuditReaderImplementor extends AuditReader {
+ SessionImplementor getSessionImplementor();
+ Session getSession();
+ FirstLevelCache getFirstLevelCache();
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java (from
rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/VersionsSync.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,160 @@
+/*
+ * 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.synchronization;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Queue;
+import javax.transaction.Synchronization;
+
+import org.hibernate.envers.revisioninfo.RevisionInfoGenerator;
+import org.hibernate.envers.synchronization.work.AuditWorkUnit;
+import org.hibernate.envers.tools.Pair;
+
+import org.hibernate.FlushMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.event.EventSource;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditSync implements Synchronization {
+ private final RevisionInfoGenerator revisionInfoGenerator;
+ private final AuditSyncManager manager;
+ private final EventSource session;
+
+ private final Transaction transaction;
+ private final LinkedList<AuditWorkUnit> workUnits;
+ private final Queue<AuditWorkUnit> undoQueue;
+ private final Map<Pair<String, Object>, AuditWorkUnit> usedIds;
+
+ private Object revisionData;
+
+ public AuditSync(AuditSyncManager manager, EventSource session, RevisionInfoGenerator
revisionInfoGenerator) {
+ this.manager = manager;
+ this.session = session;
+ this.revisionInfoGenerator = revisionInfoGenerator;
+
+ transaction = session.getTransaction();
+ workUnits = new LinkedList<AuditWorkUnit>();
+ undoQueue = new LinkedList<AuditWorkUnit>();
+ usedIds = new HashMap<Pair<String, Object>, AuditWorkUnit>();
+ }
+
+ private void removeWorkUnit(AuditWorkUnit vwu) {
+ workUnits.remove(vwu);
+ if (vwu.isPerformed()) {
+ // If this work unit has already been performed, it must be deleted (undone)
first.
+ undoQueue.offer(vwu);
+ }
+ }
+
+ public void addWorkUnit(AuditWorkUnit vwu) {
+ if (vwu.containsWork()) {
+ Object entityId = vwu.getEntityId();
+
+ if (entityId == null) {
+ // Just adding the work unit - it's not associated with any
persistent entity.
+ workUnits.offer(vwu);
+ } else {
+ String entityName = vwu.getEntityName();
+ Pair<String, Object> usedIdsKey = Pair.make(entityName, entityId);
+
+ if (usedIds.containsKey(usedIdsKey)) {
+ AuditWorkUnit other = usedIds.get(usedIdsKey);
+
+ // The entity with entityId has two work units; checking which one
should be kept.
+ switch (vwu.dispatch(other)) {
+ case FIRST:
+ // Simply not adding the second
+ break;
+
+ case SECOND:
+ removeWorkUnit(other);
+ usedIds.put(usedIdsKey, vwu);
+ workUnits.offer(vwu);
+ break;
+
+ case NONE:
+ removeWorkUnit(other);
+ break;
+ }
+ } else {
+ usedIds.put(usedIdsKey, vwu);
+ workUnits.offer(vwu);
+ }
+ }
+ }
+ }
+
+ private void executeInSession(Session session) {
+ if (revisionData == null) {
+ revisionData = revisionInfoGenerator.generate(session);
+ }
+
+ AuditWorkUnit vwu;
+
+ // First undoing any performed work units
+ while ((vwu = undoQueue.poll()) != null) {
+ vwu.undo(session);
+ }
+
+ while ((vwu = workUnits.poll()) != null) {
+ vwu.perform(session, revisionData);
+ }
+ }
+
+ public void beforeCompletion() {
+ if (workUnits.size() == 0 && undoQueue.size() == 0) {
+ return;
+ }
+
+ // see:
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178431
+ if (FlushMode.isManualFlushMode(session.getFlushMode()) || session.isClosed()) {
+ Session temporarySession = null;
+ try {
+ temporarySession = session.getFactory().openTemporarySession();
+
+ executeInSession(temporarySession);
+
+ temporarySession.flush();
+ } finally {
+ if (temporarySession != null) {
+ temporarySession.close();
+ }
+ }
+ } else {
+ executeInSession(session);
+
+ // Explicity flushing the session, as the auto-flush may have already
happened.
+ session.flush();
+ }
+ }
+
+ public void afterCompletion(int i) {
+ manager.remove(transaction);
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSyncManager.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/VersionsSyncManager.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSyncManager.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/AuditSyncManager.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,66 @@
+/*
+ * 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.synchronization;
+
+import java.util.Map;
+
+import org.hibernate.envers.revisioninfo.RevisionInfoGenerator;
+import org.hibernate.envers.tools.ConcurrentReferenceHashMap;
+
+import org.hibernate.Transaction;
+import org.hibernate.event.EventSource;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditSyncManager {
+ private final Map<Transaction, AuditSync> versionsSyncs;
+ private final RevisionInfoGenerator revisionInfoGenerator;
+
+ public AuditSyncManager(RevisionInfoGenerator revisionInfoGenerator) {
+ versionsSyncs = new ConcurrentReferenceHashMap<Transaction, AuditSync>(10,
+ ConcurrentReferenceHashMap.ReferenceType.WEAK,
+ ConcurrentReferenceHashMap.ReferenceType.STRONG);
+
+ this.revisionInfoGenerator = revisionInfoGenerator;
+ }
+
+ public AuditSync get(EventSource session) {
+ Transaction transaction = session.getTransaction();
+
+ AuditSync verSync = versionsSyncs.get(transaction);
+ if (verSync == null) {
+ verSync = new AuditSync(this, session, revisionInfoGenerator);
+ versionsSyncs.put(transaction, verSync);
+
+ transaction.registerSynchronization(verSync);
+ }
+
+ return verSync;
+ }
+
+ public void remove(Transaction transaction) {
+ versionsSyncs.remove(transaction);
+ }
+}
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractVersionsWorkUnit.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,86 @@
+/*
+ * 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.synchronization.work;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.envers.RevisionType;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
+
+import org.hibernate.Session;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public abstract class AbstractAuditWorkUnit implements AuditWorkUnit {
+ protected final AuditConfiguration verCfg;
+ protected final Serializable id;
+
+ private final String entityName;
+
+ private Object performedData;
+
+ protected AbstractAuditWorkUnit(String entityName, AuditConfiguration verCfg,
Serializable id) {
+ this.verCfg = verCfg;
+ this.id = id;
+ this.entityName = entityName;
+ }
+
+ protected void fillDataWithId(Map<String, Object> data, Object revision,
RevisionType revisionType) {
+ AuditEntitiesConfiguration entitiesCfg = verCfg.getVerEntCfg();
+
+ Map<String, Object> originalId = new HashMap<String, Object>();
+ originalId.put(entitiesCfg.getRevisionPropName(), revision);
+
+ verCfg.getEntCfg().get(getEntityName()).getIdMapper().mapToMapFromId(originalId,
id);
+ data.put(entitiesCfg.getRevisionTypePropName(), revisionType);
+ data.put(entitiesCfg.getOriginalIdPropName(), originalId);
+ }
+
+ public Object getEntityId() {
+ return id;
+ }
+
+ public boolean isPerformed() {
+ return performedData != null;
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ protected void setPerformed(Object performedData) {
+ this.performedData = performedData;
+ }
+
+ public void undo(Session session) {
+ if (isPerformed()) {
+ session.delete(verCfg.getVerEntCfg().getVersionsEntityName(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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AddWorkUnit.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.Map;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.Session;
import org.hibernate.persister.entity.EntityPersister;
@@ -36,11 +36,11 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class AddWorkUnit extends AbstractVersionsWorkUnit implements VersionsWorkUnit {
+public class AddWorkUnit extends AbstractAuditWorkUnit implements AuditWorkUnit {
private final Object[] state;
private final String[] propertyNames;
- public AddWorkUnit(String entityName, VersionsConfiguration verCfg, Serializable id,
+ public AddWorkUnit(String entityName, AuditConfiguration verCfg, Serializable id,
EntityPersister entityPersister, Object[] state) {
super(entityName, verCfg, id);
Copied:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AuditWorkUnit.java
(from rev 15455,
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/VersionsWorkUnit.java)
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AuditWorkUnit.java
(rev 0)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AuditWorkUnit.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -0,0 +1,41 @@
+/*
+ * 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.synchronization.work;
+
+import org.hibernate.Session;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public interface AuditWorkUnit extends KeepCheckVisitor, KeepCheckDispatcher {
+ Object getEntityId();
+ String getEntityName();
+
+ boolean containsWork();
+
+ boolean isPerformed();
+
+ void perform(Session session, Object revisionData);
+ void undo(Session session);
+}
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/CollectionChangeWorkUnit.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,17 +28,17 @@
import java.util.Map;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.Session;
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class CollectionChangeWorkUnit extends AbstractVersionsWorkUnit implements
VersionsWorkUnit {
+public class CollectionChangeWorkUnit extends AbstractAuditWorkUnit implements
AuditWorkUnit {
private final Object entity;
- public CollectionChangeWorkUnit(String entityName, VersionsConfiguration verCfg,
Serializable id, Object entity) {
+ public CollectionChangeWorkUnit(String entityName, AuditConfiguration verCfg,
Serializable id, Object entity) {
super(entityName, verCfg, id);
this.entity = entity;
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/DelWorkUnit.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,15 +28,15 @@
import java.util.Map;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.Session;
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class DelWorkUnit extends AbstractVersionsWorkUnit implements VersionsWorkUnit {
- public DelWorkUnit(String entityName, VersionsConfiguration verCfg, Serializable id)
{
+public class DelWorkUnit extends AbstractAuditWorkUnit implements AuditWorkUnit {
+ public DelWorkUnit(String entityName, AuditConfiguration verCfg, Serializable id) {
super(entityName, verCfg, id);
}
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-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/ModWorkUnit.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.Map;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.VersionsConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.Session;
import org.hibernate.persister.entity.EntityPersister;
@@ -36,11 +36,11 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class ModWorkUnit extends AbstractVersionsWorkUnit implements VersionsWorkUnit {
+public class ModWorkUnit extends AbstractAuditWorkUnit implements AuditWorkUnit {
private final Map<String, Object> data;
private final boolean changes;
- public ModWorkUnit(String entityName, VersionsConfiguration verCfg, Serializable id,
+ public ModWorkUnit(String entityName, AuditConfiguration verCfg, Serializable id,
EntityPersister entityPersister, Object[] newState, Object[]
oldState) {
super(entityName, verCfg, id);
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/PersistentCollectionChangeWorkUnit.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/PersistentCollectionChangeWorkUnit.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/PersistentCollectionChangeWorkUnit.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -27,8 +27,8 @@
import java.util.List;
import java.util.Map;
-import org.hibernate.envers.configuration.VersionsConfiguration;
-import org.hibernate.envers.configuration.VersionsEntitiesConfiguration;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
import org.hibernate.Session;
@@ -37,11 +37,11 @@
/**
* @author Adam Warski (adam at warski dot org)
*/
-public class PersistentCollectionChangeWorkUnit extends AbstractVersionsWorkUnit
implements VersionsWorkUnit {
+public class PersistentCollectionChangeWorkUnit extends AbstractAuditWorkUnit implements
AuditWorkUnit {
private final List<PersistentCollectionChangeData> collectionChanges;
private final String referencingPropertyName;
- public PersistentCollectionChangeWorkUnit(String entityName, VersionsConfiguration
verCfg,
+ public PersistentCollectionChangeWorkUnit(String entityName, AuditConfiguration
verCfg,
PersistentCollection collection, String
role,
Serializable snapshot, Serializable id) {
super(entityName, verCfg, null);
@@ -58,7 +58,7 @@
@SuppressWarnings({"unchecked"})
public void perform(Session session, Object revisionData) {
- VersionsEntitiesConfiguration entitiesCfg = verCfg.getVerEntCfg();
+ AuditEntitiesConfiguration entitiesCfg = verCfg.getVerEntCfg();
for (PersistentCollectionChangeData persistentCollectionChangeData :
collectionChanges) {
// Setting the revision number
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLog.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLog.java 2008-10-31
11:42:38 UTC (rev 15459)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLog.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,7 +26,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* A simple logger facade which delegates through reflection to a logging delegate.
@@ -44,19 +44,19 @@
try {
errorMethod = delegate.getClass().getMethod("error", argClass);
} catch (NoSuchMethodException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
try {
warnMethod = delegate.getClass().getMethod("warn", argClass);
} catch (NoSuchMethodException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
try {
infoMethod = delegate.getClass().getMethod("info", argClass);
} catch (NoSuchMethodException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -64,9 +64,9 @@
try {
errorMethod.invoke(delegate, message);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -74,9 +74,9 @@
try {
warnMethod.invoke(delegate, message);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -84,9 +84,9 @@
try {
infoMethod.invoke(delegate, message);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLogManager.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLogManager.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/tools/log/YLogManager.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,7 +26,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* A class for creating logging facades either to loggers obtained from
@@ -47,7 +47,7 @@
getLogMethod = logFactoryClass.getMethod("getLog",
Class.class);
argClass = Object.class;
} catch (NoSuchMethodException e) {
- throw new VersionsException("No 'getLog' method in
org.apache.commons.logging.LogFactory.");
+ throw new AuditException("No 'getLog' method in
org.apache.commons.logging.LogFactory.");
}
} catch (ClassNotFoundException e) {
try {
@@ -56,10 +56,10 @@
getLogMethod = loggerFactoryClass.getMethod("getLogger",
Class.class);
argClass = String.class;
} catch (NoSuchMethodException e1) {
- throw new VersionsException("No 'getLogger' method in
org.slf4j.LoggerFactory.");
+ throw new AuditException("No 'getLogger' method in
org.slf4j.LoggerFactory.");
}
} catch (ClassNotFoundException e1) {
- throw new VersionsException("No
org.apache.commons.logging.LogFactory or org.slf4j.LoggerFactory found.");
+ throw new AuditException("No org.apache.commons.logging.LogFactory
or org.slf4j.LoggerFactory found.");
}
}
}
@@ -68,9 +68,9 @@
try {
return new YLog(getLogMethod.invoke(null, cls), argClass);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/ReflectionTools.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/ReflectionTools.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/ReflectionTools.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -25,7 +25,7 @@
import java.util.Map;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.tools.ConcurrentReferenceHashMap;
import org.hibernate.envers.tools.Pair;
import static org.hibernate.envers.tools.Pair.make;
@@ -55,7 +55,7 @@
try {
return Thread.currentThread().getContextClassLoader().loadClass(name);
} catch (ClassNotFoundException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YClass.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YClass.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YClass.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* @author Adam Warski (adam at warski dot org)
@@ -50,9 +50,9 @@
try {
return (String) ymc.getXClass_getNameMethod().invoke(delegate);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -60,9 +60,9 @@
try {
return new YClass(ymc,
ymc.getXClass_getSuperclassMethod().invoke(delegate));
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -72,9 +72,9 @@
try {
delegates = (List)
ymc.getXClass_getDeclaredPropertiesMethod().invoke(delegate, accessMode);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
List<YProperty> ret = new ArrayList<YProperty>();
@@ -90,9 +90,9 @@
//noinspection unchecked
return (T) ymc.getXClass_getAnnotationMethod().invoke(delegate, annotation);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YMethodsAndClasses.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YMethodsAndClasses.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YMethodsAndClasses.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -25,7 +25,7 @@
import java.lang.reflect.Method;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* @author Adam Warski (adam at warski dot org)
@@ -54,7 +54,7 @@
try {
xClassClass = cl.loadClass("org.hibernate.reflection.XClass");
} catch (ClassNotFoundException e1) {
- throw new VersionsException("No XClass found.");
+ throw new AuditException("No XClass found.");
}
}
@@ -65,7 +65,7 @@
try {
xPropertyClass =
cl.loadClass("org.hibernate.reflection.XProperty");
} catch (ClassNotFoundException e1) {
- throw new VersionsException("No XProperty found.");
+ throw new AuditException("No XProperty found.");
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YProperty.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YProperty.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YProperty.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,7 +26,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
/**
* @author Adam Warski (adam at warski dot org)
@@ -44,9 +44,9 @@
try {
return (String) ymc.getXProperty_getNameMethod().invoke(delegate);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -55,9 +55,9 @@
//noinspection unchecked
return (T) ymc.getXProperty_getAnnotationMethod().invoke(delegate,
annotation);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -65,9 +65,9 @@
try {
return new YClass(ymc, ymc.getXProperty_getTypeMethod().invoke(delegate));
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
}
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YReflectionManager.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YReflectionManager.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/tools/reflection/YReflectionManager.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -25,7 +25,7 @@
import java.lang.reflect.InvocationTargetException;
-import org.hibernate.envers.exception.VersionsException;
+import org.hibernate.envers.exception.AuditException;
import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
@@ -57,9 +57,9 @@
try {
return new YClass(ymc,
ymc.getReflectionManager_classForNameMethod().invoke(delegate, className, caller));
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
@@ -67,9 +67,9 @@
try {
return (Boolean) ymc.getReflectionManager_equalsMethod().invoke(delegate,
class1.getDelegate(), class2);
} catch (IllegalAccessException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
} catch (InvocationTargetException e) {
- throw new VersionsException(e);
+ throw new AuditException(e);
}
}
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/CustomRevEntityQuery.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/CustomRevEntityQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/CustomRevEntityQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -26,7 +26,7 @@
import java.util.List;
import javax.persistence.EntityManager;
-import org.hibernate.envers.query.VersionsRestrictions;
+import org.hibernate.envers.query.AuditRestrictions;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrIntTestEntity;
import org.hibernate.envers.test.entities.reventity.CustomRevEntity;
@@ -79,7 +79,7 @@
public void testRevisionsOfId1Query() {
List<Object[]> result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.idEq(id1))
.getResultList();
assert result.get(0)[0].equals(new StrIntTestEntity("a", 10, id1));
@@ -95,7 +95,7 @@
public void testRevisionsOfId2Query() {
List<Object[]> result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.idEq(id2))
.getResultList();
assert result.get(0)[0].equals(new StrIntTestEntity("b", 15, id2));
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/DeletedEntities.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/DeletedEntities.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/DeletedEntities.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import org.hibernate.envers.DefaultRevisionEntity;
import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.query.VersionsRestrictions;
+import org.hibernate.envers.query.AuditRestrictions;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrIntTestEntity;
import org.testng.annotations.BeforeClass;
@@ -88,7 +88,7 @@
public void testRevisionsOfEntityWithoutDelete() {
List result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, false)
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.idEq(id2))
.getResultList();
assert result.size() == 1;
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/MaximalizePropertyQuery.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/MaximalizePropertyQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/MaximalizePropertyQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import javax.persistence.EntityManager;
import org.hibernate.envers.query.RevisionProperty;
-import org.hibernate.envers.query.VersionsRestrictions;
+import org.hibernate.envers.query.AuditRestrictions;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrIntTestEntity;
import org.testng.annotations.BeforeClass;
@@ -104,8 +104,8 @@
List revs_id1 = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
- .add(VersionsRestrictions.maximizeProperty("number")
- .add(VersionsRestrictions.idEq(id2)))
+ .add(AuditRestrictions.maximizeProperty("number")
+ .add(AuditRestrictions.idEq(id2)))
.getResultList();
assert Arrays.asList(2, 3, 4).equals(revs_id1);
@@ -116,8 +116,8 @@
List result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
- .add(VersionsRestrictions.minimizeProperty("number")
- .add(VersionsRestrictions.eq("str1", "a")))
+ .add(AuditRestrictions.minimizeProperty("number")
+ .add(AuditRestrictions.eq("str1", "a")))
.getResultList();
assert Arrays.asList(1).equals(result);
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/RevisionConstraintQuery.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/RevisionConstraintQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/RevisionConstraintQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import javax.persistence.EntityManager;
import org.hibernate.envers.query.RevisionProperty;
-import org.hibernate.envers.query.VersionsRestrictions;
+import org.hibernate.envers.query.AuditRestrictions;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrIntTestEntity;
import org.testng.annotations.BeforeClass;
@@ -126,7 +126,7 @@
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
.add(RevisionProperty.le(3))
- .add(VersionsRestrictions.eq("str1", "a"))
+ .add(AuditRestrictions.eq("str1", "a"))
.getResultList();
assert Arrays.asList(1).equals(result);
@@ -138,7 +138,7 @@
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
.add(RevisionProperty.gt(1))
- .add(VersionsRestrictions.lt("number", 10))
+ .add(AuditRestrictions.lt("number", 10))
.getResultList();
assert Arrays.asList(3, 4).equals(result);
@@ -152,7 +152,7 @@
.addProjection(RevisionProperty.count())
.addProjection(RevisionProperty.countDistinct())
.addProjection(RevisionProperty.min())
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.idEq(id1))
.getSingleResult();
assert (Integer) result[0] == 4;
@@ -166,7 +166,7 @@
List result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.idEq(id1))
.addOrder(RevisionProperty.desc())
.getResultList();
@@ -179,7 +179,7 @@
Object result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.count())
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.idEq(id1))
.getSingleResult();
assert (Long) result == 4;
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/SimpleQuery.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/SimpleQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/SimpleQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -32,7 +32,7 @@
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.query.RevisionProperty;
import org.hibernate.envers.query.RevisionTypeProperty;
-import org.hibernate.envers.query.VersionsRestrictions;
+import org.hibernate.envers.query.AuditRestrictions;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.StrIntTestEntity;
import org.hibernate.envers.test.tools.TestTools;
@@ -108,7 +108,7 @@
public void testEntitiesIdQuery() {
StrIntTestEntity ver2 = (StrIntTestEntity) getVersionsReader().createQuery()
.forEntitiesAtRevision(StrIntTestEntity.class, 2)
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.idEq(id2))
.getSingleResult();
assert ver2.equals(new StrIntTestEntity("a", 20, id2));
@@ -118,17 +118,17 @@
public void testEntitiesPropertyEqualsQuery() {
List ver1 = getVersionsReader().createQuery()
.forEntitiesAtRevision(StrIntTestEntity.class, 1)
- .add(VersionsRestrictions.eq("str1", "a"))
+ .add(AuditRestrictions.eq("str1", "a"))
.getResultList();
List ver2 = getVersionsReader().createQuery()
.forEntitiesAtRevision(StrIntTestEntity.class, 2)
- .add(VersionsRestrictions.eq("str1", "a"))
+ .add(AuditRestrictions.eq("str1", "a"))
.getResultList();
List ver3 = getVersionsReader().createQuery()
.forEntitiesAtRevision(StrIntTestEntity.class, 3)
- .add(VersionsRestrictions.eq("str1", "a"))
+ .add(AuditRestrictions.eq("str1", "a"))
.getResultList();
assert new HashSet(ver1).equals(TestTools.makeSet(new
StrIntTestEntity("a", 10, id1),
@@ -142,17 +142,17 @@
public void testEntitiesPropertyLeQuery() {
List ver1 = getVersionsReader().createQuery()
.forEntitiesAtRevision(StrIntTestEntity.class, 1)
- .add(VersionsRestrictions.le("number", 10))
+ .add(AuditRestrictions.le("number", 10))
.getResultList();
List ver2 = getVersionsReader().createQuery()
.forEntitiesAtRevision(StrIntTestEntity.class, 2)
- .add(VersionsRestrictions.le("number", 10))
+ .add(AuditRestrictions.le("number", 10))
.getResultList();
List ver3 = getVersionsReader().createQuery()
.forEntitiesAtRevision(StrIntTestEntity.class, 3)
- .add(VersionsRestrictions.le("number", 10))
+ .add(AuditRestrictions.le("number", 10))
.getResultList();
assert new HashSet(ver1).equals(TestTools.makeSet(new
StrIntTestEntity("a", 10, id1),
@@ -168,22 +168,22 @@
List revs_id1 = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
- .add(VersionsRestrictions.le("str1", "a"))
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.le("str1", "a"))
+ .add(AuditRestrictions.idEq(id1))
.getResultList();
List revs_id2 = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
- .add(VersionsRestrictions.le("str1", "a"))
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.le("str1", "a"))
+ .add(AuditRestrictions.idEq(id2))
.getResultList();
List revs_id3 = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionProperty.revisionNumber())
- .add(VersionsRestrictions.le("str1", "a"))
- .add(VersionsRestrictions.idEq(id3))
+ .add(AuditRestrictions.le("str1", "a"))
+ .add(AuditRestrictions.idEq(id3))
.getResultList();
assert Arrays.asList(1).equals(revs_id1);
@@ -195,7 +195,7 @@
public void testSelectEntitiesQuery() {
List result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, true, false)
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.idEq(id1))
.getResultList();
assert result.size() == 2;
@@ -208,7 +208,7 @@
public void testSelectEntitiesAndRevisionsQuery() {
List result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.idEq(id1))
.getResultList();
assert result.size() == 3;
@@ -231,7 +231,7 @@
List result = getVersionsReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
.addProjection(RevisionTypeProperty.revisionType())
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.idEq(id1))
.getResultList();
assert result.size() == 3;
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/EmbIdOneToManyQuery.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/EmbIdOneToManyQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/EmbIdOneToManyQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.Set;
import javax.persistence.EntityManager;
-import org.hibernate.envers.query.VersionsRestrictions;
+import org.hibernate.envers.query.AuditRestrictions;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.ids.EmbId;
import org.hibernate.envers.test.entities.onetomany.ids.SetRefEdEmbIdEntity;
@@ -105,32 +105,32 @@
public void testEntitiesReferencedToId3() {
Set rev1_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
.getResultList());
Set rev1 = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
- .add(VersionsRestrictions.eq("reference", new
SetRefEdEmbIdEntity(id3, null)))
+ .add(AuditRestrictions.eq("reference", new
SetRefEdEmbIdEntity(id3, null)))
.getResultList());
Set rev2_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
.getResultList());
Set rev2 = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
- .add(VersionsRestrictions.eq("reference", new
SetRefEdEmbIdEntity(id3, null)))
+ .add(AuditRestrictions.eq("reference", new
SetRefEdEmbIdEntity(id3, null)))
.getResultList());
Set rev3_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
.getResultList());
Set rev3 = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
- .add(VersionsRestrictions.eq("reference", new
SetRefEdEmbIdEntity(id3, null)))
+ .add(AuditRestrictions.eq("reference", new
SetRefEdEmbIdEntity(id3, null)))
.getResultList());
assert rev1.equals(rev1_related);
@@ -147,17 +147,17 @@
public void testEntitiesReferencedToId4() {
Set rev1_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id4))
+ .add(AuditRestrictions.relatedIdEq("reference", id4))
.getResultList());
Set rev2_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id4))
+ .add(AuditRestrictions.relatedIdEq("reference", id4))
.getResultList());
Set rev3_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id4))
+ .add(AuditRestrictions.relatedIdEq("reference", id4))
.getResultList());
assert rev1_related.equals(TestTools.makeSet());
@@ -169,20 +169,20 @@
public void testEntitiesReferencedByIng1ToId3() {
List rev1_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id1))
.getResultList();
Object rev2_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id1))
.getSingleResult();
Object rev3_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id1))
.getSingleResult();
assert rev1_related.size() == 0;
@@ -194,20 +194,20 @@
public void testEntitiesReferencedByIng2ToId3() {
List rev1_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id2))
.getResultList();
List rev2_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id2))
.getResultList();
Object rev3_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id2))
.getSingleResult();
assert rev1_related.size() == 0;
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/MulIdOneToManyQuery.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/MulIdOneToManyQuery.java 2008-10-31
11:42:38 UTC (rev 15459)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/MulIdOneToManyQuery.java 2008-10-31
11:53:38 UTC (rev 15460)
@@ -28,7 +28,7 @@
import java.util.Set;
import javax.persistence.EntityManager;
-import org.hibernate.envers.query.VersionsRestrictions;
+import org.hibernate.envers.query.AuditRestrictions;
import org.hibernate.envers.test.AbstractEntityTest;
import org.hibernate.envers.test.entities.ids.MulId;
import org.hibernate.envers.test.entities.onetomany.ids.SetRefEdMulIdEntity;
@@ -105,32 +105,32 @@
public void testEntitiesReferencedToId3() {
Set rev1_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
.getResultList());
Set rev1 = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
- .add(VersionsRestrictions.eq("reference", new
SetRefEdMulIdEntity(id3, null)))
+ .add(AuditRestrictions.eq("reference", new
SetRefEdMulIdEntity(id3, null)))
.getResultList());
Set rev2_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
.getResultList());
Set rev2 = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
- .add(VersionsRestrictions.eq("reference", new
SetRefEdMulIdEntity(id3, null)))
+ .add(AuditRestrictions.eq("reference", new
SetRefEdMulIdEntity(id3, null)))
.getResultList());
Set rev3_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
.getResultList());
Set rev3 = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
- .add(VersionsRestrictions.eq("reference", new
SetRefEdMulIdEntity(id3, null)))
+ .add(AuditRestrictions.eq("reference", new
SetRefEdMulIdEntity(id3, null)))
.getResultList());
assert rev1.equals(rev1_related);
@@ -147,17 +147,17 @@
public void testEntitiesReferencedToId4() {
Set rev1_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id4))
+ .add(AuditRestrictions.relatedIdEq("reference", id4))
.getResultList());
Set rev2_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id4))
+ .add(AuditRestrictions.relatedIdEq("reference", id4))
.getResultList());
Set rev3_related = new HashSet(getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id4))
+ .add(AuditRestrictions.relatedIdEq("reference", id4))
.getResultList());
assert rev1_related.equals(TestTools.makeSet());
@@ -169,20 +169,20 @@
public void testEntitiesReferencedByIng1ToId3() {
List rev1_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id1))
.getResultList();
Object rev2_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id1))
.getSingleResult();
Object rev3_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id1))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id1))
.getSingleResult();
assert rev1_related.size() == 0;
@@ -194,20 +194,20 @@
public void testEntitiesReferencedByIng2ToId3() {
List rev1_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id2))
.getResultList();
List rev2_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id2))
.getResultList();
Object rev3_related = getVersionsReader().createQuery()
.forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
- .add(VersionsRestrictions.relatedIdEq("reference", id3))
- .add(VersionsRestrictions.idEq(id2))
+ .add(AuditRestrictions.relatedIdEq("reference", id3))
+ .add(AuditRestrictions.idEq(id2))
.getSingleResult();
assert rev1_related.size() == 0;