[hibernate-commits] Hibernate SVN: r15589 - in core/trunk/envers/src: main/java/org/hibernate/envers/configuration/metadata and 12 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Nov 19 08:10:40 EST 2008


Author: adamw
Date: 2008-11-19 08:10:40 -0500 (Wed, 19 Nov 2008)
New Revision: 15589

Added:
   core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditEntity.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditId.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditProperty.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditRelatedId.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/order/PropertyAuditOrder.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/PropertyAuditProjection.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/property/
   core/trunk/envers/src/main/java/org/hibernate/envers/query/property/EntityPropertyName.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/property/OriginalIdPropertyName.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/property/PropertyNameGetter.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionNumberPropertyName.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionPropertyPropertyName.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionTypePropertyName.java
Removed:
   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/AggregatedFieldAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java
Modified:
   core/trunk/envers/src/main/java/org/hibernate/envers/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/entities/mapper/relation/OneToOneNotOwningMapper.java
   core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.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/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/query/AuditQuery.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/BetweenAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java
   core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.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/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/synchronization/work/AbstractAuditWorkUnit.java
   core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/PersistentCollectionChangeWorkUnit.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/AggregateQuery.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/OrderByLimitQuery.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-3611: improved query interface

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -37,8 +37,9 @@
 
     private final String originalIdPropName;
 
-    private final String revisionPropName;
-    private final String revisionPropPath;
+    private final String revisionFieldName;
+    private final String revisionNumberPath;
+    private final String revisionPropBasePath;
 
     private final String revisionTypePropName;
     private final String revisionTypePropType;
@@ -55,28 +56,37 @@
 
         originalIdPropName = "originalId";
 
-        revisionPropName = properties.getProperty("org.hibernate.envers.revisionFieldName", "REV");
+        revisionFieldName = properties.getProperty("org.hibernate.envers.revisionFieldName", "REV");
 
         revisionTypePropName = properties.getProperty("org.hibernate.envers.revisionTypeFieldName", "REVTYPE");
         revisionTypePropType = "byte";
 
         customAuditTablesNames = new HashMap<String, String>();
 
-        revisionPropPath = originalIdPropName + "." + revisionPropName + ".id";
+        revisionNumberPath = originalIdPropName + "." + revisionFieldName + ".id";
+        revisionPropBasePath = originalIdPropName + "." + revisionFieldName + ".";
     }
 
     public String getOriginalIdPropName() {
         return originalIdPropName;
     }
 
-    public String getRevisionPropName() {
-        return revisionPropName;
+    public String getRevisionFieldName() {
+        return revisionFieldName;
     }
 
-    public String getRevisionPropPath() {
-        return revisionPropPath;
+    public String getRevisionNumberPath() {
+        return revisionNumberPath;
     }
 
+    /**
+     * @param propertyName Property of the revision entity.
+     * @return A path to the given property of the revision entity associated with an audit entity.
+     */
+    public String getRevisionPropPath(String propertyName) {
+        return revisionPropBasePath + propertyName;
+    }
+
     public String getRevisionTypePropName() {
         return revisionTypePropName;
     }

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -88,8 +88,8 @@
 
     void addRevisionInfoRelation(Element any_mapping) {
         Element rev_mapping = (Element) revisionInfoRelationMapping.clone();
-        rev_mapping.addAttribute("name", verEntCfg.getRevisionPropName());
-        MetadataTools.addColumn(rev_mapping, verEntCfg.getRevisionPropName(), null);
+        rev_mapping.addAttribute("name", verEntCfg.getRevisionFieldName());
+        MetadataTools.addColumn(rev_mapping, verEntCfg.getRevisionFieldName(), null);
 
         any_mapping.add(rev_mapping);
     }
@@ -192,7 +192,7 @@
 
             Element joinKey = joinElement.addElement("key");
             MetadataTools.addColumns(joinKey, join.getKey().getColumnIterator());
-            MetadataTools.addColumn(joinKey, verEntCfg.getRevisionPropName(), null);
+            MetadataTools.addColumn(joinKey, verEntCfg.getRevisionFieldName(), null);
         }
     }
 
@@ -298,7 +298,7 @@
                 // Adding the "key" element with all columns + the revision number column
                 Element keyMapping = mappingData.getFirst().addElement("key");
                 MetadataTools.addColumns(keyMapping, pc.getIdentifierProperty().getColumnIterator());
-                MetadataTools.addColumn(keyMapping, verEntCfg.getRevisionPropName(), null);
+                MetadataTools.addColumn(keyMapping, verEntCfg.getRevisionFieldName(), null);
                 break;
 
             case TABLE_PER_CLASS:

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/OneToOneNotOwningMapper.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -33,7 +33,7 @@
 import org.hibernate.envers.entities.mapper.PropertyMapper;
 import org.hibernate.envers.entities.PropertyData;
 import org.hibernate.envers.exception.AuditException;
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 import org.hibernate.envers.reader.AuditReaderImplementor;
 import org.hibernate.envers.tools.reflection.ReflectionTools;
 
@@ -71,7 +71,7 @@
 
         try {
             value = versionsReader.createQuery().forEntitiesAtRevision(entityClass, revision)
-                    .add(AuditRestrictions.relatedIdEq(owningReferencePropertyName, primaryKey)).getSingleResult();
+                    .add(AuditEntity.relatedId(owningReferencePropertyName).eq(primaryKey)).getSingleResult();
         } catch (NoResultException e) {
             value = null;
         } catch (NonUniqueResultException e) {

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -62,7 +62,7 @@
          * (only non-deleted entities)
          *     e.revision_type != DEL
          */
-        String revisionPropertyPath = verEntCfg.getRevisionPropPath();
+        String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
         String originalIdPropertyName = verEntCfg.getOriginalIdPropName();
 
         String versionsReferencedEntityName = verEntCfg.getAuditEntityName(referencedEntityName);

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -61,7 +61,7 @@
          * (only non-deleted entities and associations)
          *     ee.revision_type != DEL
          */
-        String revisionPropertyPath = verEntCfg.getRevisionPropPath();
+        String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
         String originalIdPropertyName = verEntCfg.getOriginalIdPropName();
 
         // SELECT new list(ee) FROM middleEntity ee

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/ThreeEntityQueryGenerator.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -78,7 +78,7 @@
          *     e.revision_type != DEL AND
          *     f.revision_type != DEL
          */
-        String revisionPropertyPath = verEntCfg.getRevisionPropPath();
+        String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
         String originalIdPropertyName = verEntCfg.getOriginalIdPropName();
 
         String eeOriginalIdPropertyPath = "ee." + originalIdPropertyName;

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityQueryGenerator.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -71,7 +71,7 @@
          *     ee.revision_type != DEL AND
          *     e.revision_type != DEL
          */
-        String revisionPropertyPath = verEntCfg.getRevisionPropPath();
+        String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
         String originalIdPropertyName = verEntCfg.getOriginalIdPropName();
 
         String eeOriginalIdPropertyPath = "ee." + originalIdPropertyName;

Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditEntity.java (from rev 15586, core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditRestrictions.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditEntity.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditEntity.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,122 @@
+/*
+ * 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.query.criteria.AuditCriterion;
+import org.hibernate.envers.query.criteria.*;
+import org.hibernate.envers.query.property.EntityPropertyName;
+import org.hibernate.envers.query.property.RevisionNumberPropertyName;
+import org.hibernate.envers.query.property.RevisionPropertyPropertyName;
+import org.hibernate.envers.query.property.RevisionTypePropertyName;
+import org.hibernate.envers.RevisionType;
+
+/**
+ * TODO: ilike
+ * @author Adam Warski (adam at warski dot org)
+ * @see org.hibernate.criterion.Restrictions
+ */
+ at SuppressWarnings({"JavaDoc"})
+public class AuditEntity {
+    private AuditEntity() { }
+
+    public static AuditId id() {
+        return new AuditId();
+    }
+
+    /**
+     * Create restrictions, projections and specify order for a property of an audited entity.
+     * @param propertyName Name of the property.
+     */
+    public static AuditProperty<Object> property(String propertyName) {
+        return new AuditProperty<Object>(new EntityPropertyName(propertyName));
+    }
+
+   /**
+     * Create restrictions, projections and specify order for the revision number, corresponding to an
+     * audited entity.
+     */
+    public static AuditProperty<Number> revisionNumber() {
+        return new AuditProperty<Number>(new RevisionNumberPropertyName());
+    }
+
+    /**
+     * Create restrictions, projections and specify order for a property of the revision entity,
+     * corresponding to an audited entity.
+     * @param propertyName Name of the property.
+     */
+    public static AuditProperty<Object> revisionProperty(String propertyName) {
+        return new AuditProperty<Object>(new RevisionPropertyPropertyName(propertyName));
+    }
+
+    /**
+     * Create restrictions, projections and specify order for the revision type, corresponding to an
+     * audited entity.
+     */
+    public static AuditProperty<RevisionType> revisionType() {
+        return new AuditProperty<RevisionType>(new RevisionTypePropertyName());
+    }
+
+    /**
+	 * Create restrictions on an id of a related entity.
+     * @param propertyName Name of the property, which is the relation.
+	 */
+	public static AuditRelatedId relatedId(String propertyName) {
+		return new AuditRelatedId(new EntityPropertyName(propertyName));
+	}
+
+    /**
+	 * Return the conjuction of two criterions.
+	 */
+	public static AuditCriterion and(AuditCriterion lhs, AuditCriterion rhs) {
+		return new LogicalAuditExpression(lhs, rhs, "and");
+	}
+
+    /**
+	 * Return the disjuction of two criterions.
+	 */
+	public static AuditCriterion or(AuditCriterion lhs, AuditCriterion rhs) {
+		return new LogicalAuditExpression(lhs, rhs, "or");
+	}
+
+    /**
+	 * Return the negation of a criterion.
+	 */
+	public static AuditCriterion not(AuditCriterion expression) {
+		return new NotAuditExpression(expression);
+	}
+
+	/**
+	 * Group criterions together in a single conjunction (A and B and C...).
+	 */
+	public static AuditConjunction conjunction() {
+		return new AuditConjunction();
+	}
+
+	/**
+	 * Group criterions together in a single disjunction (A or B or C...).
+	 */
+	public static AuditDisjunction disjunction() {
+		return new AuditDisjunction();
+	}
+}

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQuery.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQuery.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/AuditQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -47,12 +47,8 @@
 
     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);

Deleted: core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionProperty.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -1,143 +0,0 @@
-/*
- * 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.criteria.RevisionAuditExpression;
-import org.hibernate.envers.query.criteria.AuditCriterion;
-import org.hibernate.envers.query.order.RevisionAuditOrder;
-import org.hibernate.envers.query.order.AuditOrder;
-import org.hibernate.envers.query.projection.RevisionAuditProjection;
-import org.hibernate.envers.query.projection.AuditProjection;
-import org.hibernate.envers.tools.Triple;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
- at SuppressWarnings({"JavaDoc"})
-public class RevisionProperty implements AuditProjection {
-    private RevisionProperty() { }
-
-    /**
-     * Apply a "equal" constraint on the revision number
-     */
-    public static AuditCriterion eq(Integer revision) {
-        return new RevisionAuditExpression(revision, "=");
-    }
-
-    /**
-     * Apply a "not equal" constraint on the revision number
-     */
-    public static AuditCriterion ne(Integer revision) {
-        return new RevisionAuditExpression(revision, "<>");
-    }
-
-    /**
-     * Apply a "greater than" constraint on the revision number
-     */
-    public static AuditCriterion gt(Integer revision) {
-        return new RevisionAuditExpression(revision, ">");
-    }
-
-    /**
-     * Apply a "greater than or equal" constraint on the revision number
-     */
-    public static AuditCriterion ge(Integer revision) {
-        return new RevisionAuditExpression(revision, ">=");
-    }
-
-    /**
-     * Apply a "less than" constraint on the revision number
-     */
-    public static AuditCriterion lt(Integer revision) {
-        return new RevisionAuditExpression(revision, "<");
-    }
-
-    /**
-     * Apply a "less than or equal" constraint on the revision number
-     */
-    public static AuditCriterion le(Integer revision) {
-        return new RevisionAuditExpression(revision, "<=");
-    }
-
-    /**
-     * Sort the results by revision in ascending order
-     */
-    public static AuditOrder asc() {
-        return new RevisionAuditOrder(true);
-    }
-
-    /**
-     * Sort the results by revision in descending order
-     */
-    public static AuditOrder desc() {
-        return new RevisionAuditOrder(false);
-    }
-
-    /**
-     * Select the maximum revision
-     */
-    public static AuditProjection max() {
-        return new RevisionAuditProjection(RevisionAuditProjection.ProjectionType.MAX);
-    }
-
-    /**
-     * Select the minimum revision
-     */
-    public static AuditProjection min() {
-        return new RevisionAuditProjection(RevisionAuditProjection.ProjectionType.MIN);
-    }
-
-    /**
-     * Count revisions
-     */
-    public static AuditProjection count() {
-        return new RevisionAuditProjection(RevisionAuditProjection.ProjectionType.COUNT);
-    }
-
-    /**
-     * Count distinct revisions
-     */
-    public static AuditProjection countDistinct() {
-        return new RevisionAuditProjection(RevisionAuditProjection.ProjectionType.COUNT_DISTINCT);
-    }
-
-    /**
-     * Distinct revisions
-     */
-    public static AuditProjection distinct() {
-        return new RevisionAuditProjection(RevisionAuditProjection.ProjectionType.DISTINCT);
-    }
-
-    /**
-     * Projection the revision number
-     */
-    public static AuditProjection revisionNumber() {
-        return new RevisionProperty();
-    }
-
-    public Triple<String, String, Boolean> getData(AuditConfiguration verCfg) {
-        return Triple.make(null, verCfg.getAuditEntCfg().getRevisionPropPath(), false);
-    }
-}

Deleted: 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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/RevisionTypeProperty.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -1,64 +0,0 @@
-/*
- * 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.projection.AuditProjection;
-import org.hibernate.envers.query.criteria.AuditCriterion;
-import org.hibernate.envers.query.criteria.RevisionTypeAuditExpression;
-import org.hibernate.envers.tools.Triple;
-import org.hibernate.envers.RevisionType;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
- at SuppressWarnings({"JavaDoc"})
-public class RevisionTypeProperty implements AuditProjection {
-    private RevisionTypeProperty() { }
-
-    /**
-     * Apply a "equal" constraint on the revision type
-     */
-    public static AuditCriterion eq(RevisionType type) {
-        return new RevisionTypeAuditExpression(type, "=");
-    }
-
-    /**
-     * Apply a "not equal" constraint on the revision type
-     */
-    public static AuditCriterion ne(RevisionType type) {
-        return new RevisionTypeAuditExpression(type, "<>");
-    }
-
-    /**
-     * Projection on the revision type
-     */
-    public static AuditProjection revisionType() {
-        return new RevisionTypeProperty();
-    }
-
-    public Triple<String, String, Boolean> getData(AuditConfiguration verCfg) {
-        return Triple.make(null, verCfg.getAuditEntCfg().getRevisionTypePropName(), false);
-    }
-}
\ No newline at end of file

Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java (from rev 15586, core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,85 @@
+/*
+ * 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.query.property.PropertyNameGetter;
+import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.tools.query.Parameters;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AggregatedAuditExpression implements AuditCriterion, ExtendableCriterion {
+    private PropertyNameGetter propertyNameGetter;
+    private AggregatedMode mode;
+    private List<AuditCriterion> criterions;
+
+    public AggregatedAuditExpression(PropertyNameGetter propertyNameGetter, AggregatedMode mode) {
+        this.propertyNameGetter = propertyNameGetter;
+        this.mode = mode;
+        criterions = new ArrayList<AuditCriterion>();
+    }
+
+    public static enum AggregatedMode {
+        MAX,
+        MIN
+    }
+
+    public AggregatedAuditExpression add(AuditCriterion criterion) {
+        criterions.add(criterion);
+        return this;
+    }
+
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
+        String propertyName = propertyNameGetter.get(auditCfg);
+
+        CriteriaTools.checkPropertyNotARelation(auditCfg, entityName, propertyName);
+
+        // This will be the aggregated query, containing all the specified conditions
+        QueryBuilder subQb = qb.newSubQueryBuilder();
+
+        // Adding all specified conditions both to the main query, as well as to the
+        // aggregated one.
+        for (AuditCriterion versionsCriteria : criterions) {
+            versionsCriteria.addToQuery(auditCfg, entityName, qb, parameters);
+            versionsCriteria.addToQuery(auditCfg, entityName, subQb, subQb.getRootParameters());
+        }
+
+        // Setting the desired projection of the aggregated query
+        switch (mode) {
+            case MIN:
+                subQb.addProjection("min", propertyName, false);
+                break;
+            case MAX:
+                subQb.addProjection("max", propertyName, false);
+        }
+
+        // Adding the constrain on the result of the aggregated criteria
+        parameters.addWhere(propertyName, "=", subQb);
+    }
+}
\ No newline at end of file

Deleted: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedFieldAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -1,82 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
- */
-package org.hibernate.envers.query.criteria;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.envers.configuration.AuditConfiguration;
-import org.hibernate.envers.tools.query.Parameters;
-import org.hibernate.envers.tools.query.QueryBuilder;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class AggregatedFieldAuditExpression implements AuditCriterion, ExtendableCriterion {
-    public static enum AggregatedMode {
-        MAX,
-        MIN
-    }
-
-    private String propertyName;
-    private AggregatedMode mode;
-    private List<AuditCriterion> criterions;
-
-    public AggregatedFieldAuditExpression(String propertyName, AggregatedMode mode) {
-        this.propertyName = propertyName;
-        this.mode = mode;
-        criterions = new ArrayList<AuditCriterion>();
-    }
-
-    public AggregatedFieldAuditExpression add(AuditCriterion criterion) {
-        criterions.add(criterion);
-        return this;
-    }
-
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
-
-        // This will be the aggregated query, containing all the specified conditions
-        QueryBuilder subQb = qb.newSubQueryBuilder();
-
-        // Adding all specified conditions both to the main query, as well as to the
-        // aggregated one.
-        for (AuditCriterion versionsCriteria : criterions) {
-            versionsCriteria.addToQuery(verCfg, entityName, qb, parameters);
-            versionsCriteria.addToQuery(verCfg, entityName, subQb, subQb.getRootParameters());
-        }
-
-        // Setting the desired projection of the aggregated query
-        switch (mode) {
-            case MIN:
-                subQb.addProjection("min", propertyName, false);
-                break;
-            case MAX:
-                subQb.addProjection("max", propertyName, false);
-        }
-
-        // Adding the constrain on the result of the aggregated criteria
-        parameters.addWhere(propertyName, "=", subQb);
-    }
-}
\ No newline at end of file

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditCriterion.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditCriterion.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditCriterion.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -31,5 +31,5 @@
  * @author Adam Warski (adam at warski dot org)
  */
 public interface AuditCriterion {
-    void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters);
+    void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters);
 }

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditId.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditId.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditId.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,61 @@
+/*
+ * 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.query.projection.AuditProjection;
+import org.hibernate.envers.query.projection.PropertyAuditProjection;
+import org.hibernate.envers.query.property.OriginalIdPropertyName;
+
+/**
+ * Create restrictions and projections for the id of an audited entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at SuppressWarnings({"JavaDoc"})
+public class AuditId {
+    /**
+	 * Apply an "equal" constraint
+	 */
+	public AuditCriterion eq(Object id) {
+		return new IdentifierEqAuditExpression(id, true);
+	}
+
+    /**
+	 * Apply a "not equal" constraint
+	 */
+	public AuditCriterion ne(Object id) {
+		return new IdentifierEqAuditExpression(id, false);
+	}
+
+    // Projections
+
+    /**
+     * Projection counting the values
+     * TODO: idPropertyName isn't needed, should be read from the configuration
+     * @param idPropertyName Name of the identifier property
+     */
+    public AuditProjection count(String idPropertyName) {
+        return new PropertyAuditProjection(new OriginalIdPropertyName(idPropertyName), "count", false);
+    }
+}
\ No newline at end of file

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditProperty.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditProperty.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditProperty.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,266 @@
+/*
+ * 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.query.property.PropertyNameGetter;
+import org.hibernate.envers.query.order.AuditOrder;
+import org.hibernate.envers.query.order.PropertyAuditOrder;
+import org.hibernate.envers.query.projection.AuditProjection;
+import org.hibernate.envers.query.projection.PropertyAuditProjection;
+import org.hibernate.envers.tools.Triple;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.criterion.MatchMode;
+
+import java.util.Collection;
+
+/**
+ * Create restrictions, projections and specify order for a property of an audited entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at SuppressWarnings({"JavaDoc"})
+public class AuditProperty<T> implements AuditProjection {
+    private final PropertyNameGetter propertyNameGetter;
+
+    public AuditProperty(PropertyNameGetter propertyNameGetter) {
+        this.propertyNameGetter = propertyNameGetter;
+    }
+
+    /**
+	 * Apply an "equal" constraint
+	 */
+	public AuditCriterion eq(T value) {
+		return new SimpleAuditExpression(propertyNameGetter, value, "=");
+	}
+
+    /**
+	 * Apply a "not equal" constraint
+	 */
+	public AuditCriterion ne(T value) {
+		return new SimpleAuditExpression(propertyNameGetter, value, "<>");
+	}
+
+    /**
+	 * Apply a "like" constraint
+	 */
+	public AuditCriterion like(T value) {
+		return new SimpleAuditExpression(propertyNameGetter, value, " like ");
+	}
+
+    /**
+	 * Apply a "like" constraint
+	 */
+	public AuditCriterion like(String value, MatchMode matchMode) {
+		return new SimpleAuditExpression(propertyNameGetter, matchMode.toMatchString(value), " like " );
+	}
+
+    /**
+	 * Apply a "greater than" constraint
+	 */
+	public AuditCriterion gt(T value) {
+		return new SimpleAuditExpression(propertyNameGetter, value, ">");
+	}
+
+    /**
+	 * Apply a "less than" constraint
+	 */
+	public AuditCriterion lt(T value) {
+		return new SimpleAuditExpression(propertyNameGetter, value, "<");
+	}
+
+    /**
+	 * Apply a "less than or equal" constraint
+	 */
+	public AuditCriterion le(T value) {
+		return new SimpleAuditExpression(propertyNameGetter, value, "<=");
+	}
+
+    /**
+	 * Apply a "greater than or equal" constraint
+	 */
+	public AuditCriterion ge(T value) {
+		return new SimpleAuditExpression(propertyNameGetter, value, ">=");
+	}
+
+    /**
+	 * Apply a "between" constraint
+	 */
+	public AuditCriterion between(T lo, T hi) {
+		return new BetweenAuditExpression(propertyNameGetter, lo, hi);
+	}
+
+    /**
+	 * Apply an "in" constraint
+	 */
+	public AuditCriterion in(T[] values) {
+		return new InAuditExpression(propertyNameGetter, values);
+	}
+
+    /**
+	 * Apply an "in" constraint
+	 */
+	public AuditCriterion in(Collection values) {
+		return new InAuditExpression(propertyNameGetter, values.toArray());
+	}
+
+    /**
+	 * Apply an "is null" constraint
+	 */
+	public AuditCriterion isNull() {
+		return new NullAuditExpression(propertyNameGetter);
+	}
+
+    /**
+	 * Apply an "equal" constraint to another property
+	 */
+	public AuditCriterion eqProperty(String otherPropertyName) {
+		return new PropertyAuditExpression(propertyNameGetter, otherPropertyName, "=");
+	}
+
+    /**
+	 * Apply a "not equal" constraint to another property
+	 */
+	public AuditCriterion neProperty(String otherPropertyName) {
+		return new PropertyAuditExpression(propertyNameGetter, otherPropertyName, "<>");
+	}
+
+    /**
+	 * Apply a "less than" constraint to another property
+	 */
+	public AuditCriterion ltProperty(String otherPropertyName) {
+		return new PropertyAuditExpression(propertyNameGetter, otherPropertyName, "<");
+	}
+
+    /**
+	 * Apply a "less than or equal" constraint to another property
+	 */
+	public AuditCriterion leProperty(String otherPropertyName) {
+		return new PropertyAuditExpression(propertyNameGetter, otherPropertyName, "<=");
+	}
+
+    /**
+	 * Apply a "greater than" constraint to another property
+	 */
+	public AuditCriterion gtProperty(String otherPropertyName) {
+		return new PropertyAuditExpression(propertyNameGetter, otherPropertyName, ">");
+	}
+
+    /**
+	 * Apply a "greater than or equal" constraint to another property
+	 */
+	public AuditCriterion geProperty(String otherPropertyName) {
+		return new PropertyAuditExpression(propertyNameGetter, otherPropertyName, ">=");
+	}
+
+    /**
+	 * Apply an "is not null" constraint to the another property
+	 */
+	public AuditCriterion isNotNull() {
+		return new NotNullAuditExpression(propertyNameGetter);
+	}
+
+    /**
+     * Apply a "maximalize" constraint, with the ability to specify further constraints on the maximized
+     * property
+     */
+    public AggregatedAuditExpression maximize() {
+        return new AggregatedAuditExpression(propertyNameGetter,
+                AggregatedAuditExpression.AggregatedMode.MAX);
+    }
+
+    /**
+     * Apply a "minimize" constraint, with the ability to specify further constraints on the minimized
+     * property
+     */
+    public AggregatedAuditExpression minimize() {
+        return new AggregatedAuditExpression(propertyNameGetter,
+                AggregatedAuditExpression.AggregatedMode.MIN);
+    }
+
+    // Projections
+
+    /**
+     * Projection on the maximum value
+     */
+    public AuditProjection max() {
+        return new PropertyAuditProjection(propertyNameGetter, "max", false);
+    }
+
+    /**
+     * Projection on the minimum value
+     */
+    public AuditProjection min() {
+        return new PropertyAuditProjection(propertyNameGetter, "min", false);
+    }
+
+    /**
+     * Projection counting the values
+     */
+    public AuditProjection count() {
+        return new PropertyAuditProjection(propertyNameGetter, "count", false);
+    }
+
+    /**
+     * Projection counting distinct values
+     */
+    public AuditProjection countDistinct() {
+        return new PropertyAuditProjection(propertyNameGetter, "count", true);
+    }
+
+    /**
+     * Projection on distinct values
+     */
+    public AuditProjection distinct() {
+        return new PropertyAuditProjection(propertyNameGetter, null, true);
+    }
+
+    /**
+     * Projection using a custom function
+     */
+    public AuditProjection function(String functionName) {
+        return new PropertyAuditProjection(propertyNameGetter, functionName, false);
+    }
+
+    // Projection on this property
+
+    public Triple<String, String, Boolean> getData(AuditConfiguration auditCfg) {
+        return Triple.make(null, propertyNameGetter.get(auditCfg), false);
+    }
+
+    // Order
+
+    /**
+     * Sort the results by the property in ascending order
+     */
+    public AuditOrder asc() {
+        return new PropertyAuditOrder(propertyNameGetter, true);
+    }
+
+    /**
+     * Sort the results by the property in descending order
+     */
+    public AuditOrder desc() {
+        return new PropertyAuditOrder(propertyNameGetter, false);
+    }
+}

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditRelatedId.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditRelatedId.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/AuditRelatedId.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,54 @@
+/*
+ * 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.query.property.PropertyNameGetter;
+
+/**
+ * Create restrictions on an id of an entity related to an audited entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at SuppressWarnings({"JavaDoc"})
+public class AuditRelatedId {
+    private final PropertyNameGetter propertyNameGetter;
+
+    public AuditRelatedId(PropertyNameGetter propertyNameGetter) {
+        this.propertyNameGetter = propertyNameGetter;
+    }
+
+    /**
+	 * Apply an "equal" constraint
+	 */
+	public AuditCriterion eq(Object id) {
+		return new RelatedAuditExpression(propertyNameGetter, id, true);
+	}
+
+    /**
+	 * Apply a "not equal" constraint
+	 */
+	public AuditCriterion ne(Object id) {
+		return new RelatedAuditExpression(propertyNameGetter, id, false);
+	}
+}
\ No newline at end of file

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/BetweenAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -26,23 +26,25 @@
 import org.hibernate.envers.configuration.AuditConfiguration;
 import org.hibernate.envers.tools.query.Parameters;
 import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.query.property.PropertyNameGetter;
 
 /**
  * @author Adam Warski (adam at warski dot org)
  */
 public class BetweenAuditExpression implements AuditCriterion {
-    private String propertyName;
+    private PropertyNameGetter propertyNameGetter;
     private Object lo;
     private Object hi;
 
-    public BetweenAuditExpression(String propertyName, Object lo, Object hi) {
-        this.propertyName = propertyName;
+    public BetweenAuditExpression(PropertyNameGetter propertyNameGetter, Object lo, Object hi) {
+        this.propertyNameGetter = propertyNameGetter;
         this.lo = lo;
         this.hi = hi;
     }
 
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
+        String propertyName = propertyNameGetter.get(auditCfg);
+        CriteriaTools.checkPropertyNotARelation(auditCfg, entityName, propertyName);
         parameters.addWhereWithParam(propertyName, ">=", lo);
         parameters.addWhereWithParam(propertyName, "<=", hi);
     }

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/IdentifierEqAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -28,17 +28,20 @@
 import org.hibernate.envers.tools.query.QueryBuilder;
 
 /**
+ * A criterion that expresses that the id of an entity is equal or not equal to some specified value.
  * @author Adam Warski (adam at warski dot org)
  */
 public class IdentifierEqAuditExpression implements AuditCriterion {
-    private Object id;
+    private final Object id;
+    private final boolean equals;
 
-    public IdentifierEqAuditExpression(Object id) {
+    public IdentifierEqAuditExpression(Object id, boolean equals) {
         this.id = id;
+        this.equals = equals;
     }
 
     public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
         verCfg.getEntCfg().get(entityName).getIdMapper()
-                .addIdEqualsToQuery(parameters, id, verCfg.getAuditEntCfg().getOriginalIdPropName(), true);
+                .addIdEqualsToQuery(parameters, id, verCfg.getAuditEntCfg().getOriginalIdPropName(), equals);
     }
 }

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/InAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -26,21 +26,23 @@
 import org.hibernate.envers.configuration.AuditConfiguration;
 import org.hibernate.envers.tools.query.Parameters;
 import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.query.property.PropertyNameGetter;
 
 /**
  * @author Adam Warski (adam at warski dot org)
  */
 public class InAuditExpression implements AuditCriterion {
-    private String propertyName;
+    private PropertyNameGetter propertyNameGetter;
     private Object[] values;
 
-    public InAuditExpression(String propertyName, Object[] values) {
-        this.propertyName = propertyName;
+    public InAuditExpression(PropertyNameGetter propertyNameGetter, Object[] values) {
+        this.propertyNameGetter = propertyNameGetter;
         this.values = values;
     }
 
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
+        String propertyName = propertyNameGetter.get(auditCfg);
+        CriteriaTools.checkPropertyNotARelation(auditCfg, entityName, propertyName);
         parameters.addWhereWithParams(propertyName, "in (", values, ")");
     }
 }

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NotNullAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -27,19 +27,21 @@
 import org.hibernate.envers.entities.RelationDescription;
 import org.hibernate.envers.tools.query.Parameters;
 import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.query.property.PropertyNameGetter;
 
 /**
  * @author Adam Warski (adam at warski dot org)
  */
 public class NotNullAuditExpression implements AuditCriterion {
-    private String propertyName;
+    private PropertyNameGetter propertyNameGetter;
 
-    public NotNullAuditExpression(String propertyName) {
-        this.propertyName = propertyName;
+    public NotNullAuditExpression(PropertyNameGetter propertyNameGetter) {
+        this.propertyNameGetter = propertyNameGetter;
     }
 
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg, entityName, propertyName);
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
+        String propertyName = propertyNameGetter.get(auditCfg);
+        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(auditCfg, entityName, propertyName);
 
         if (relatedEntity == null) {
             parameters.addWhereWithParam(propertyName, "<>", null);

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/NullAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -27,19 +27,21 @@
 import org.hibernate.envers.entities.RelationDescription;
 import org.hibernate.envers.tools.query.Parameters;
 import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.query.property.PropertyNameGetter;
 
 /**
  * @author Adam Warski (adam at warski dot org)
  */
 public class NullAuditExpression implements AuditCriterion {
-    private String propertyName;
+    private PropertyNameGetter propertyNameGetter;
 
-    public NullAuditExpression(String propertyName) {
-        this.propertyName = propertyName;
+    public NullAuditExpression(PropertyNameGetter propertyNameGetter) {
+        this.propertyNameGetter = propertyNameGetter;
     }
 
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg, entityName, propertyName);
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
+        String propertyName = propertyNameGetter.get(auditCfg);
+        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(auditCfg, entityName, propertyName);
 
         if (relatedEntity == null) {
             parameters.addWhereWithParam(propertyName, "=", null);

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/PropertyAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -26,24 +26,26 @@
 import org.hibernate.envers.configuration.AuditConfiguration;
 import org.hibernate.envers.tools.query.Parameters;
 import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.query.property.PropertyNameGetter;
 
 /**
  * @author Adam Warski (adam at warski dot org)
  */
 public class PropertyAuditExpression implements AuditCriterion {
-    private String propertyName;
+    private PropertyNameGetter propertyNameGetter;
     private String otherPropertyName;
     private String op;
 
-    public PropertyAuditExpression(String propertyName, String otherPropertyName, String op) {
-        this.propertyName = propertyName;
+    public PropertyAuditExpression(PropertyNameGetter propertyNameGetter, String otherPropertyName, String op) {
+        this.propertyNameGetter = propertyNameGetter;
         this.otherPropertyName = otherPropertyName;
         this.op = op;
     }
 
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        CriteriaTools.checkPropertyNotARelation(verCfg, entityName, propertyName);
-        CriteriaTools.checkPropertyNotARelation(verCfg, entityName, otherPropertyName);
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {   
+        String propertyName = propertyNameGetter.get(auditCfg);
+        CriteriaTools.checkPropertyNotARelation(auditCfg, entityName, propertyName);
+        CriteriaTools.checkPropertyNotARelation(auditCfg, entityName, otherPropertyName);
         parameters.addWhere(propertyName, op, otherPropertyName);
     }
 }

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RelatedAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -28,23 +28,26 @@
 import org.hibernate.envers.exception.AuditException;
 import org.hibernate.envers.tools.query.Parameters;
 import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.query.property.PropertyNameGetter;
 
 /**
  * @author Adam Warski (adam at warski dot org)
  */
 public class RelatedAuditExpression implements AuditCriterion {
-    private String propertyName;
-    private Object id;
-    private boolean equals;
+    private final PropertyNameGetter propertyNameGetter;
+    private final Object id;
+    private final boolean equals;
 
-    public RelatedAuditExpression(String propertyName, Object id, boolean equals) {
-        this.propertyName = propertyName;
+    public RelatedAuditExpression(PropertyNameGetter propertyNameGetter, Object id, boolean equals) {
+        this.propertyNameGetter = propertyNameGetter;
         this.id = id;
         this.equals = equals;
     }
 
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg, entityName, propertyName);
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
+        String propertyName = propertyNameGetter.get(auditCfg);
+        
+        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(auditCfg, entityName, propertyName);
 
         if (relatedEntity == null) {
             throw new AuditException("This criterion can only be used on a property that is " +

Deleted: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/RevisionAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -1,45 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
- */
-package org.hibernate.envers.query.criteria;
-
-import org.hibernate.envers.configuration.AuditConfiguration;
-import org.hibernate.envers.tools.query.Parameters;
-import org.hibernate.envers.tools.query.QueryBuilder;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class RevisionAuditExpression implements AuditCriterion {
-    private Object value;
-    private String op;
-
-    public RevisionAuditExpression(Object value, String op) {
-        this.value = value;
-        this.op = op;
-    }
-
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        parameters.addWhereWithParam(verCfg.getAuditEntCfg().getRevisionPropPath(), op, value);
-    }
-}
\ No newline at end of file

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/criteria/SimpleAuditExpression.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -28,24 +28,27 @@
 import org.hibernate.envers.exception.AuditException;
 import org.hibernate.envers.tools.query.Parameters;
 import org.hibernate.envers.tools.query.QueryBuilder;
+import org.hibernate.envers.query.property.PropertyNameGetter;
 
 /**
  * @author Adam Warski (adam at warski dot org)
  */
 public class SimpleAuditExpression implements AuditCriterion {
-    private String propertyName;
+    private PropertyNameGetter propertyNameGetter;
     private Object value;
     private String op;
 
-    public SimpleAuditExpression(String propertyName, Object value, String op) {
-        this.propertyName = propertyName;
+    public SimpleAuditExpression(PropertyNameGetter propertyNameGetter, Object value, String op) {
+        this.propertyNameGetter = propertyNameGetter;
         this.value = value;
         this.op = op;
     }
 
-    public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
-        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(verCfg, entityName, propertyName);
+    public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
+        String propertyName = propertyNameGetter.get(auditCfg);
 
+        RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(auditCfg, entityName, propertyName);
+
         if (relatedEntity == null) {
             parameters.addWhereWithParam(propertyName, op, value);
         } else {

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/AbstractAuditQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -121,12 +121,6 @@
 
     // Projection and order
 
-    public AuditQuery addProjection(String function, String propertyName) {
-        hasProjection = true;
-        qb.addProjection(function, propertyName, false);
-        return this;
-    }
-
     public AuditQuery addProjection(AuditProjection projection) {
         Triple<String, String, Boolean> projectionData = projection.getData(verCfg);
         hasProjection = true;
@@ -134,15 +128,12 @@
         return this;
     }
 
-    public AuditQuery addOrder(String propertyName, boolean asc) {
+    public AuditQuery addOrder(AuditOrder order) {
         hasOrder = true;
-        qb.addOrder(propertyName, asc);
-        return this;
-    }
 
-    public AuditQuery addOrder(AuditOrder order) {
         Pair<String, Boolean> orderData = order.getData(verCfg);
-        return addOrder(orderData.getFirst(), orderData.getSecond());
+        qb.addOrder(orderData.getFirst(), orderData.getSecond());
+        return this;
     }
 
     // Query properties

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/EntitiesAtRevisionQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -61,7 +61,7 @@
 
         AuditEntitiesConfiguration verEntCfg = verCfg.getAuditEntCfg();
 
-        String revisionPropertyPath = verEntCfg.getRevisionPropPath();
+        String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
         String originalIdPropertyName = verEntCfg.getOriginalIdPropName();
 
         // SELECT max(e2.revision)

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/RevisionsOfEntityQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -57,7 +57,7 @@
         AuditEntitiesConfiguration verEntCfg = verCfg.getAuditEntCfg();
 
         String originalId = verEntCfg.getOriginalIdPropName();
-        String revisionPropertyName = verEntCfg.getRevisionPropName();
+        String revisionPropertyName = verEntCfg.getRevisionFieldName();
 
         Object revisionInfoObject = ((Map) versionsEntity.get(originalId)).get(revisionPropertyName);
 
@@ -92,13 +92,13 @@
         }
 
         if (!hasProjection && !hasOrder) {
-            String revisionPropertyPath = verEntCfg.getRevisionPropPath();
+            String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
             qb.addOrder(revisionPropertyPath, true);
         }
 
         if (!selectEntitiesOnly) {
             qb.addFrom(verCfg.getAuditEntCfg().getRevisionInfoEntityName(), "r");
-            qb.getRootParameters().addWhere(verCfg.getAuditEntCfg().getRevisionPropPath(), true, "=", "r.id", false);
+            qb.getRootParameters().addWhere(verCfg.getAuditEntCfg().getRevisionNumberPath(), true, "=", "r.id", false);
         }
 
         List<Object> queryResult = buildAndExecuteQuery();

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/order/AuditOrder.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/order/AuditOrder.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/order/AuditOrder.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -31,8 +31,8 @@
  */
 public interface AuditOrder {
     /**
-     * @param verCfg Configuration.
+     * @param auditCfg Configuration.
      * @return A pair: (property name, ascending?).
      */
-    Pair<String, Boolean> getData(AuditConfiguration verCfg);
+    Pair<String, Boolean> getData(AuditConfiguration auditCfg);
 }

Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/order/PropertyAuditOrder.java (from rev 15586, core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/order/PropertyAuditOrder.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/order/PropertyAuditOrder.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+
+package org.hibernate.envers.query.order;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.Pair;
+import org.hibernate.envers.query.property.PropertyNameGetter;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class PropertyAuditOrder implements AuditOrder {
+    private final PropertyNameGetter propertyNameGetter;
+    private final boolean asc;
+
+    public PropertyAuditOrder(PropertyNameGetter propertyNameGetter, boolean asc) {
+        this.propertyNameGetter = propertyNameGetter;
+        this.asc = asc;
+    }
+
+    public Pair<String, Boolean> getData(AuditConfiguration auditCfg) {
+        return Pair.make(propertyNameGetter.get(auditCfg), asc);
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/main/java/org/hibernate/envers/query/order/PropertyAuditOrder.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/order/RevisionAuditOrder.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -1,43 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
- */
-package org.hibernate.envers.query.order;
-
-import org.hibernate.envers.configuration.AuditConfiguration;
-import org.hibernate.envers.tools.Pair;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class RevisionAuditOrder implements AuditOrder {
-    private final boolean asc;
-
-    public RevisionAuditOrder(boolean asc) {
-        this.asc = asc;
-    }
-
-    public Pair<String, Boolean> getData(AuditConfiguration verCfg) {
-        String revisionPropPath = verCfg.getAuditEntCfg().getRevisionPropPath();
-        return Pair.make(revisionPropPath, asc);
-    }
-}

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/AuditProjection.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/AuditProjection.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/AuditProjection.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -31,9 +31,8 @@
  */
 public interface AuditProjection {
     /**
-     *
-     * @param verCfg Configuration.
+     * @param auditCfg Configuration.
      * @return A triple: (function name - possibly null, property name, add distinct?).
      */
-    Triple<String, String, Boolean> getData(AuditConfiguration verCfg);
+    Triple<String, String, Boolean> getData(AuditConfiguration auditCfg);
 }

Copied: core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/PropertyAuditProjection.java (from rev 15586, core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java)
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/PropertyAuditProjection.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/PropertyAuditProjection.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+
+package org.hibernate.envers.query.projection;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.tools.Triple;
+import org.hibernate.envers.query.property.PropertyNameGetter;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class PropertyAuditProjection implements AuditProjection {
+    private final PropertyNameGetter propertyNameGetter;
+    private final String function;
+    private final boolean distinct;
+
+    public PropertyAuditProjection(PropertyNameGetter propertyNameGetter, String function, boolean distinct) {
+        this.propertyNameGetter = propertyNameGetter;
+        this.function = function;
+        this.distinct = distinct;
+    }
+
+    public Triple<String, String, Boolean> getData(AuditConfiguration auditCfg) {
+        String propertyName = propertyNameGetter.get(auditCfg);
+
+        return Triple.make(function, propertyName, distinct);
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/PropertyAuditProjection.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/projection/RevisionAuditProjection.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -1,60 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
- */
-package org.hibernate.envers.query.projection;
-
-import org.hibernate.envers.configuration.AuditConfiguration;
-import org.hibernate.envers.tools.Triple;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class RevisionAuditProjection implements AuditProjection {
-    public static enum ProjectionType {
-        MAX,
-        MIN,
-        COUNT,
-        COUNT_DISTINCT,
-        DISTINCT
-    }
-
-    private final ProjectionType type;
-
-    public RevisionAuditProjection(ProjectionType type) {
-        this.type = type;
-    }
-
-    public Triple<String, String, Boolean> getData(AuditConfiguration verCfg) {
-        String revisionPropPath = verCfg.getAuditEntCfg().getRevisionPropPath();
-
-        switch (type) {
-            case MAX: return Triple.make("max", revisionPropPath, false);
-            case MIN: return Triple.make("min", revisionPropPath, false);
-            case COUNT: return Triple.make("count", revisionPropPath, false);
-            case COUNT_DISTINCT: return Triple.make("count", revisionPropPath, true); 
-            case DISTINCT: return Triple.make(null, revisionPropPath, true);
-        }
-
-        throw new IllegalArgumentException("Unknown type " + type + ".");
-    }
-}

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/property/EntityPropertyName.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/property/EntityPropertyName.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/property/EntityPropertyName.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+
+package org.hibernate.envers.query.property;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+
+/**
+ * Used for specifying restrictions on a property of an audited entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class EntityPropertyName implements PropertyNameGetter {
+    private final String propertyName;
+
+    public EntityPropertyName(String propertyName) {
+        this.propertyName = propertyName;
+    }
+
+    public String get(AuditConfiguration auditCfg) {
+        return propertyName;
+    }
+}

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/property/OriginalIdPropertyName.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/property/OriginalIdPropertyName.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/property/OriginalIdPropertyName.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+
+package org.hibernate.envers.query.property;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+
+/**
+ * Used for specifying restrictions on the identifier.
+ * TODO: idPropertyName should be read basing on auditCfg + entityName
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class OriginalIdPropertyName implements PropertyNameGetter {
+    private final String idPropertyName;
+
+    public OriginalIdPropertyName(String idPropertyName) {
+        this.idPropertyName = idPropertyName;
+    }
+
+    public String get(AuditConfiguration auditCfg) {
+        return auditCfg.getAuditEntCfg().getOriginalIdPropName() + "." + idPropertyName;
+    }
+}
\ No newline at end of file

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/property/PropertyNameGetter.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/property/PropertyNameGetter.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/property/PropertyNameGetter.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -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.property;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+
+/**
+ * Provides a function to get the name of a property, which is used in a query, to apply some restrictions on it.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public interface PropertyNameGetter {
+    /**
+     * @param auditCfg Audit configuration.
+     * @return Name of the property, to be used in a query.
+     */
+    public String get(AuditConfiguration auditCfg);
+}

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionNumberPropertyName.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionNumberPropertyName.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionNumberPropertyName.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,37 @@
+/*
+ * 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.property;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+
+/**
+ * Used for specifying restrictions on the revision number, corresponding to an audit entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionNumberPropertyName implements PropertyNameGetter {
+    public String get(AuditConfiguration auditCfg) {
+        return auditCfg.getAuditEntCfg().getRevisionNumberPath();
+    }
+}
\ No newline at end of file

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionPropertyPropertyName.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionPropertyPropertyName.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionPropertyPropertyName.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+
+package org.hibernate.envers.query.property;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+
+/**
+ * Used for specifying restrictions on a property of the revision entity, which is associated with an audit entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionPropertyPropertyName implements PropertyNameGetter {
+    private final String propertyName;
+
+    public RevisionPropertyPropertyName(String propertyName) {
+        this.propertyName = propertyName;
+    }
+
+    public String get(AuditConfiguration auditCfg) {
+        return auditCfg.getAuditEntCfg().getRevisionPropPath(propertyName);
+    }
+}
\ No newline at end of file

Added: core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionTypePropertyName.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionTypePropertyName.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/property/RevisionTypePropertyName.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -0,0 +1,37 @@
+/*
+ * 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.property;
+
+import org.hibernate.envers.configuration.AuditConfiguration;
+
+/**
+ * Used for specifying restrictions on the revision number, corresponding to an audit entity.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionTypePropertyName implements PropertyNameGetter {
+    public String get(AuditConfiguration auditCfg) {
+        return auditCfg.getAuditEntCfg().getRevisionTypePropName();
+    }
+}
\ No newline at end of file

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/reader/AuditReaderImpl.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -31,8 +31,7 @@
 import org.hibernate.envers.exception.NotAuditedException;
 import org.hibernate.envers.exception.RevisionDoesNotExistException;
 import org.hibernate.envers.exception.AuditException;
-import org.hibernate.envers.query.RevisionProperty;
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull;
 import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
 
@@ -101,7 +100,7 @@
         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();
+                .add(AuditEntity.id().eq(primaryKey)).getSingleResult();
         } catch (NoResultException e) {
             result = null;
         } catch (NonUniqueResultException e) {
@@ -126,8 +125,8 @@
         }
 
         return createQuery().forRevisionsOfEntity(cls, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(AuditRestrictions.idEq(primaryKey))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.id().eq(primaryKey))
                 .getResultList();
     }
 

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/AbstractAuditWorkUnit.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -54,7 +54,7 @@
         AuditEntitiesConfiguration entitiesCfg = verCfg.getAuditEntCfg();
 
         Map<String, Object> originalId = new HashMap<String, Object>();
-        originalId.put(entitiesCfg.getRevisionPropName(), revision);
+        originalId.put(entitiesCfg.getRevisionFieldName(), revision);
 
         verCfg.getEntCfg().get(getEntityName()).getIdMapper().mapToMapFromId(originalId, id);
         data.put(entitiesCfg.getRevisionTypePropName(), revisionType);

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/synchronization/work/PersistentCollectionChangeWorkUnit.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -63,7 +63,7 @@
         for (PersistentCollectionChangeData persistentCollectionChangeData : collectionChanges) {
             // Setting the revision number
             ((Map<String, Object>) persistentCollectionChangeData.getData().get(entitiesCfg.getOriginalIdPropName()))
-                    .put(entitiesCfg.getRevisionPropName(), revisionData);
+                    .put(entitiesCfg.getRevisionFieldName(), revisionData);
 
             session.save(persistentCollectionChangeData.getEntityName(), persistentCollectionChangeData.getData());
         }

Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/AggregateQuery.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/AggregateQuery.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/AggregateQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -27,6 +27,7 @@
 
 import org.hibernate.envers.test.AbstractEntityTest;
 import org.hibernate.envers.test.entities.IntTestEntity;
+import org.hibernate.envers.query.AuditEntity;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
@@ -83,20 +84,20 @@
     public void testEntitiesAvgMaxQuery() {
         Object[] ver1 = (Object[]) getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 1)
-                .addProjection("max", "number")
-                .addProjection("avg", "number")
+                .addProjection(AuditEntity.property("number").max())
+                .addProjection(AuditEntity.property("number").function("avg"))
                 .getSingleResult();
 
         Object[] ver2 = (Object[]) getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 2)
-                .addProjection("max", "number")
-                .addProjection("avg", "number")
+                .addProjection(AuditEntity.property("number").max())
+                .addProjection(AuditEntity.property("number").function("avg"))
                 .getSingleResult();
 
         Object[] ver3 = (Object[]) getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 3)
-                .addProjection("max", "number")
-                .addProjection("avg", "number")
+                .addProjection(AuditEntity.property("number").max())
+                .addProjection(AuditEntity.property("number").function("avg"))
                 .getSingleResult();
 
         assert (Integer) ver1[0] == 10;

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/CustomRevEntityQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -26,7 +26,7 @@
 import java.util.List;
 import javax.persistence.EntityManager;
 
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 import org.hibernate.envers.test.AbstractEntityTest;
 import org.hibernate.envers.test.entities.StrIntTestEntity;
 import org.hibernate.envers.test.entities.reventity.CustomRevEntity;
@@ -42,6 +42,7 @@
 public class CustomRevEntityQuery extends AbstractEntityTest {
     private Integer id1;
     private Integer id2;
+    private Long timestamp;
 
     public void configure(Ejb3Configuration cfg) {
         cfg.addAnnotatedClass(CustomRevEntity.class);
@@ -49,7 +50,7 @@
     }
 
     @BeforeClass(dependsOnMethods = "init")
-    public void initData() {
+    public void initData() throws InterruptedException {
         // Revision 1
         EntityManager em = getEntityManager();
         em.getTransaction().begin();
@@ -65,6 +66,12 @@
 
         em.getTransaction().commit();
 
+        Thread.sleep(100);
+
+        timestamp = System.currentTimeMillis();
+
+        Thread.sleep(100);
+
         // Revision 2
         em.getTransaction().begin();
 
@@ -79,7 +86,7 @@
     public void testRevisionsOfId1Query() {
         List<Object[]> result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.id().eq(id1))
                 .getResultList();
 
         assert result.get(0)[0].equals(new StrIntTestEntity("a", 10, id1));
@@ -95,11 +102,25 @@
     public void testRevisionsOfId2Query() {
         List<Object[]> result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.id().eq(id2))
                 .getResultList();
 
         assert result.get(0)[0].equals(new StrIntTestEntity("b", 15, id2));
         assert result.get(0)[1] instanceof CustomRevEntity;
         assert ((CustomRevEntity) result.get(0)[1]).getCustomId() == 1;
     }
+
+    @Test
+    public void testRevisionPropertyRestriction() {
+        List<Object[]> result = getAuditReader().createQuery()
+                .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
+                .add(AuditEntity.id().eq(id1))
+                .add(AuditEntity.revisionProperty("customTimestamp").ge(timestamp))
+                .getResultList();
+
+        assert result.get(0)[0].equals(new StrIntTestEntity("c", 10, id1));
+        assert result.get(0)[1] instanceof CustomRevEntity;
+        assert ((CustomRevEntity) result.get(0)[1]).getCustomId() == 2;  
+        assert ((CustomRevEntity) result.get(0)[1]).getCustomTimestamp() >= timestamp;
+    }
 }
\ No newline at end of file

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/DeletedEntities.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -28,7 +28,7 @@
 
 import org.hibernate.envers.DefaultRevisionEntity;
 import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 import org.hibernate.envers.test.AbstractEntityTest;
 import org.hibernate.envers.test.entities.StrIntTestEntity;
 import org.testng.annotations.BeforeClass;
@@ -79,16 +79,16 @@
             .getResultList().size() == 1;
 
         assert (Long) getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 1)
-            .addProjection("count", "originalId.id").getResultList().get(0) == 2;
+            .addProjection(AuditEntity.id().count("id")).getResultList().get(0) == 2;
         assert (Long) getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 2)
-            .addProjection("count", "originalId.id").getResultList().get(0) == 1;
+            .addProjection(AuditEntity.id().count("id")).getResultList().get(0) == 1;
     }
 
     @Test
     public void testRevisionsOfEntityWithoutDelete() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, false)
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.id().eq(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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/MaximalizePropertyQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -27,8 +27,7 @@
 import java.util.List;
 import javax.persistence.EntityManager;
 
-import org.hibernate.envers.query.RevisionProperty;
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 import org.hibernate.envers.test.AbstractEntityTest;
 import org.hibernate.envers.test.entities.StrIntTestEntity;
 import org.testng.annotations.BeforeClass;
@@ -103,9 +102,9 @@
     public void testMaximizeWithIdEq() {
         List revs_id1 = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(AuditRestrictions.maximizeProperty("number")
-                    .add(AuditRestrictions.idEq(id2)))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.property("number").maximize()
+                    .add(AuditEntity.id().eq(id2)))
                 .getResultList();
 
         assert Arrays.asList(2, 3, 4).equals(revs_id1);
@@ -115,11 +114,24 @@
     public void testMinimizeWithPropertyEq() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(AuditRestrictions.minimizeProperty("number")
-                    .add(AuditRestrictions.eq("str1", "a")))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.property("number").minimize()
+                    .add(AuditEntity.property("str1").eq("a")))
                 .getResultList();
 
         assert Arrays.asList(1).equals(result);
     }
+
+    @Test
+    public void testMaximizeRevision() {
+        List result = getAuditReader().createQuery()
+                .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.revisionNumber().maximize()
+                    .add(AuditEntity.property("number").eq(10)))
+                .getResultList();
+
+        System.out.println(result);
+        assert Arrays.asList(2).equals(result);
+    }
 }
\ No newline at end of file

Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/OrderByLimitQuery.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/OrderByLimitQuery.java	2008-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/OrderByLimitQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -29,6 +29,7 @@
 
 import org.hibernate.envers.test.AbstractEntityTest;
 import org.hibernate.envers.test.entities.IntTestEntity;
+import org.hibernate.envers.query.AuditEntity;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
@@ -92,21 +93,21 @@
     public void testEntitiesOrderLimitByQueryRev1() {
         List res_0_to_1 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 1)
-                .addOrder("number", false)
+                .addOrder(AuditEntity.property("number").desc())
                 .setFirstResult(0)
                 .setMaxResults(2)
                 .getResultList();
 
         List res_2_to_3 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 1)
-                .addOrder("number", false)
+                .addOrder(AuditEntity.property("number").desc())
                 .setFirstResult(2)
                 .setMaxResults(2)
                 .getResultList();
 
         List res_empty = getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 1)
-                .addOrder("number", false)
+                .addOrder(AuditEntity.property("number").desc())
                 .setFirstResult(4)
                 .setMaxResults(2)
                 .getResultList();
@@ -120,21 +121,21 @@
     public void testEntitiesOrderLimitByQueryRev2() {
         List res_0_to_1 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 2)
-                .addOrder("number", false)
+                .addOrder(AuditEntity.property("number").desc())
                 .setFirstResult(0)
                 .setMaxResults(2)
                 .getResultList();
 
         List res_2_to_3 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 2)
-                .addOrder("number", false)
+                .addOrder(AuditEntity.property("number").desc())
                 .setFirstResult(2)
                 .setMaxResults(2)
                 .getResultList();
 
         List res_4 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(IntTestEntity.class, 2)
-                .addOrder("number", false)
+                .addOrder(AuditEntity.property("number").desc())
                 .setFirstResult(4)
                 .setMaxResults(2)
                 .getResultList();

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/RevisionConstraintQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -27,9 +27,7 @@
 import java.util.List;
 import javax.persistence.EntityManager;
 
-import org.hibernate.envers.query.RevisionProperty;
-import org.hibernate.envers.query.AuditRestrictions;
-import org.hibernate.envers.query.RevisionTypeProperty;
+import org.hibernate.envers.query.AuditEntity;
 import org.hibernate.envers.test.AbstractEntityTest;
 import org.hibernate.envers.test.entities.StrIntTestEntity;
 import org.hibernate.envers.RevisionType;
@@ -104,8 +102,8 @@
     public void testRevisionsLtQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.distinct())
-                .add(RevisionProperty.lt(3))
+                .addProjection(AuditEntity.revisionNumber().distinct())
+                .add(AuditEntity.revisionNumber().lt(3))
                 .getResultList();
 
         assert Arrays.asList(1, 2).equals(result);
@@ -115,8 +113,8 @@
     public void testRevisionsGeQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.distinct())
-                .add(RevisionProperty.ge(2))
+                .addProjection(AuditEntity.revisionNumber().distinct())
+                .add(AuditEntity.revisionNumber().ge(2))
                 .getResultList();
 
         assert Arrays.asList(2, 3, 4).equals(result);
@@ -126,9 +124,9 @@
     public void testRevisionsLeWithPropertyQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(RevisionProperty.le(3))
-                .add(AuditRestrictions.eq("str1", "a"))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.revisionNumber().le(3))
+                .add(AuditEntity.property("str1").eq("a"))
                 .getResultList();
 
         assert Arrays.asList(1).equals(result);
@@ -138,9 +136,9 @@
     public void testRevisionsGtWithPropertyQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(RevisionProperty.gt(1))
-                .add(AuditRestrictions.lt("number", 10))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.revisionNumber().gt(1))
+                .add(AuditEntity.property("number").lt(10))
                 .getResultList();
 
         assert Arrays.asList(3, 4).equals(result);
@@ -150,11 +148,11 @@
     public void testRevisionProjectionQuery() {
         Object[] result = (Object[]) getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.max())
-                .addProjection(RevisionProperty.count())
-                .addProjection(RevisionProperty.countDistinct())
-                .addProjection(RevisionProperty.min())
-                .add(AuditRestrictions.idEq(id1))
+                .addProjection(AuditEntity.revisionNumber().max())
+                .addProjection(AuditEntity.revisionNumber().count())
+                .addProjection(AuditEntity.revisionNumber().countDistinct())
+                .addProjection(AuditEntity.revisionNumber().min())
+                .add(AuditEntity.id().eq(id1))
                 .getSingleResult();
 
         assert (Integer) result[0] == 4;
@@ -167,9 +165,9 @@
     public void testRevisionOrderQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(AuditRestrictions.idEq(id1))
-                .addOrder(RevisionProperty.desc())
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.id().eq(id1))
+                .addOrder(AuditEntity.revisionNumber().desc())
                 .getResultList();
 
         assert Arrays.asList(4, 3, 2, 1).equals(result);
@@ -180,8 +178,8 @@
         // The query shouldn't be ordered as always, otherwise - we get an exception.
         Object result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.count())
-                .add(AuditRestrictions.idEq(id1))
+                .addProjection(AuditEntity.revisionNumber().count())
+                .add(AuditEntity.id().eq(id1))
                 .getSingleResult();
 
         assert (Long) result == 4;
@@ -192,8 +190,8 @@
         // The query shouldn't be ordered as always, otherwise - we get an exception.
         List results = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, true, true)
-                .add(AuditRestrictions.idEq(id1))
-                .add(RevisionTypeProperty.eq(RevisionType.MOD))
+                .add(AuditEntity.id().eq(id1))
+                .add(AuditEntity.revisionType().eq(RevisionType.MOD))
                 .getResultList();
         
         assert results.size() == 3;
@@ -207,8 +205,8 @@
         // The query shouldn't be ordered as always, otherwise - we get an exception.
         List results = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, true, true)
-                .add(AuditRestrictions.idEq(id1))
-                .add(RevisionTypeProperty.ne(RevisionType.MOD))
+                .add(AuditEntity.id().eq(id1))
+                .add(AuditEntity.revisionType().ne(RevisionType.MOD))
                 .getResultList();
 
         assert results.size() == 1;

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/SimpleQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -30,9 +30,7 @@
 
 import org.hibernate.envers.DefaultRevisionEntity;
 import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.query.RevisionProperty;
-import org.hibernate.envers.query.RevisionTypeProperty;
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 import org.hibernate.envers.test.AbstractEntityTest;
 import org.hibernate.envers.test.entities.StrIntTestEntity;
 import org.hibernate.envers.test.tools.TestTools;
@@ -108,7 +106,7 @@
     public void testEntitiesIdQuery() {
         StrIntTestEntity ver2 = (StrIntTestEntity) getAuditReader().createQuery()
                 .forEntitiesAtRevision(StrIntTestEntity.class, 2)
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.id().eq(id2))
                 .getSingleResult();
 
         assert ver2.equals(new StrIntTestEntity("a", 20, id2));
@@ -118,17 +116,17 @@
     public void testEntitiesPropertyEqualsQuery() {
         List ver1 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(StrIntTestEntity.class, 1)
-                .add(AuditRestrictions.eq("str1", "a"))
+                .add(AuditEntity.property("str1").eq("a"))
                 .getResultList();
 
         List ver2 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(StrIntTestEntity.class, 2)
-                .add(AuditRestrictions.eq("str1", "a"))
+                .add(AuditEntity.property("str1").eq("a"))
                 .getResultList();
 
         List ver3 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(StrIntTestEntity.class, 3)
-                .add(AuditRestrictions.eq("str1", "a"))
+                .add(AuditEntity.property("str1").eq("a"))
                 .getResultList();
 
         assert new HashSet(ver1).equals(TestTools.makeSet(new StrIntTestEntity("a", 10, id1),
@@ -142,17 +140,17 @@
     public void testEntitiesPropertyLeQuery() {
         List ver1 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(StrIntTestEntity.class, 1)
-                .add(AuditRestrictions.le("number", 10))
+                .add(AuditEntity.property("number").le(10))
                 .getResultList();
 
         List ver2 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(StrIntTestEntity.class, 2)
-                .add(AuditRestrictions.le("number", 10))
+                .add(AuditEntity.property("number").le(10))
                 .getResultList();
 
         List ver3 = getAuditReader().createQuery()
                 .forEntitiesAtRevision(StrIntTestEntity.class, 3)
-                .add(AuditRestrictions.le("number", 10))
+                .add(AuditEntity.property("number").le(10))
                 .getResultList();
 
         assert new HashSet(ver1).equals(TestTools.makeSet(new StrIntTestEntity("a", 10, id1),
@@ -167,23 +165,23 @@
     public void testRevisionsPropertyEqQuery() {
         List revs_id1 = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(AuditRestrictions.le("str1", "a"))
-                .add(AuditRestrictions.idEq(id1))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.property("str1").le("a"))
+                .add(AuditEntity.id().eq(id1))
                 .getResultList();
 
         List revs_id2 = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(AuditRestrictions.le("str1", "a"))
-                .add(AuditRestrictions.idEq(id2))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.property("str1").le("a"))
+                .add(AuditEntity.id().eq(id2))
                 .getResultList();
 
         List revs_id3 = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionProperty.revisionNumber())
-                .add(AuditRestrictions.le("str1", "a"))
-                .add(AuditRestrictions.idEq(id3))
+                .addProjection(AuditEntity.revisionNumber())
+                .add(AuditEntity.property("str1").le("a"))
+                .add(AuditEntity.id().eq(id3))
                 .getResultList();
 
         assert Arrays.asList(1).equals(revs_id1);
@@ -195,7 +193,7 @@
     public void testSelectEntitiesQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, true, false)
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.id().eq(id1))
                 .getResultList();
 
         assert result.size() == 2;
@@ -208,7 +206,7 @@
     public void testSelectEntitiesAndRevisionsQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.id().eq(id1))
                 .getResultList();
 
         assert result.size() == 3;
@@ -230,8 +228,8 @@
     public void testSelectRevisionTypeQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .addProjection(RevisionTypeProperty.revisionType())
-                .add(AuditRestrictions.idEq(id1))
+                .addProjection(AuditEntity.revisionType())
+                .add(AuditEntity.id().eq(id1))
                 .getResultList();
 
         assert result.size() == 3;
@@ -254,7 +252,7 @@
     public void testEmptyConjunctionRevisionOfEntityQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .add(AuditRestrictions.conjunction())
+                .add(AuditEntity.conjunction())
                 .getResultList();
 
         assert result.size() == 7;
@@ -264,7 +262,7 @@
     public void testEmptyDisjunctionRevisionOfEntityQuery() {
         List result = getAuditReader().createQuery()
                 .forRevisionsOfEntity(StrIntTestEntity.class, false, true)
-                .add(AuditRestrictions.disjunction())
+                .add(AuditEntity.disjunction())
                 .getResultList();
 
         assert result.size() == 0;

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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/EmbIdOneToManyQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -28,7 +28,7 @@
 import java.util.Set;
 import javax.persistence.EntityManager;
 
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 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(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
+                .add(AuditEntity.relatedId("reference").eq(id3))
                 .getResultList());
 
         Set rev1 = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
-                .add(AuditRestrictions.eq("reference", new SetRefEdEmbIdEntity(id3, null)))
+                .add(AuditEntity.property("reference").eq(new SetRefEdEmbIdEntity(id3, null)))
                 .getResultList());
 
         Set rev2_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
+                .add(AuditEntity.relatedId("reference").eq(id3))
                 .getResultList());
 
         Set rev2 = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
-                .add(AuditRestrictions.eq("reference", new SetRefEdEmbIdEntity(id3, null)))
+                .add(AuditEntity.property("reference").eq(new SetRefEdEmbIdEntity(id3, null)))
                 .getResultList());
 
         Set rev3_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
+                .add(AuditEntity.relatedId("reference").eq(id3))
                 .getResultList());
 
         Set rev3 = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
-                .add(AuditRestrictions.eq("reference", new SetRefEdEmbIdEntity(id3, null)))
+                .add(AuditEntity.property("reference").eq(new SetRefEdEmbIdEntity(id3, null)))
                 .getResultList());
 
         assert rev1.equals(rev1_related);
@@ -147,17 +147,17 @@
     public void testEntitiesReferencedToId4() {
         Set rev1_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id4))
+                .add(AuditEntity.relatedId("reference").eq(id4))
                 .getResultList());
 
         Set rev2_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id4))
+                .add(AuditEntity.relatedId("reference").eq(id4))
                 .getResultList());
 
         Set rev3_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id4))
+                .add(AuditEntity.relatedId("reference").eq(id4))
                 .getResultList());
 
         assert rev1_related.equals(TestTools.makeSet());
@@ -169,20 +169,20 @@
     public void testEntitiesReferencedByIng1ToId3() {
         List rev1_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id1))
                 .getResultList();
 
         Object rev2_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id1))
                 .getSingleResult();
 
         Object rev3_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id1))
                 .getSingleResult();
 
         assert rev1_related.size() == 0;
@@ -194,20 +194,20 @@
     public void testEntitiesReferencedByIng2ToId3() {
         List rev1_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id2))
                 .getResultList();
 
         List rev2_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id2))
                 .getResultList();
 
         Object rev3_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(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-11-19 08:18:58 UTC (rev 15588)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/query/ids/MulIdOneToManyQuery.java	2008-11-19 13:10:40 UTC (rev 15589)
@@ -28,7 +28,7 @@
 import java.util.Set;
 import javax.persistence.EntityManager;
 
-import org.hibernate.envers.query.AuditRestrictions;
+import org.hibernate.envers.query.AuditEntity;
 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(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
+                .add(AuditEntity.relatedId("reference").eq(id3))
                 .getResultList());
 
         Set rev1 = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
-                .add(AuditRestrictions.eq("reference", new SetRefEdMulIdEntity(id3, null)))
+                .add(AuditEntity.property("reference").eq(new SetRefEdMulIdEntity(id3, null)))
                 .getResultList());
 
         Set rev2_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
+                .add(AuditEntity.relatedId("reference").eq(id3))
                 .getResultList());
 
         Set rev2 = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
-                .add(AuditRestrictions.eq("reference", new SetRefEdMulIdEntity(id3, null)))
+                .add(AuditEntity.property("reference").eq(new SetRefEdMulIdEntity(id3, null)))
                 .getResultList());
 
         Set rev3_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
+                .add(AuditEntity.relatedId("reference").eq(id3))
                 .getResultList());
 
         Set rev3 = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
-                .add(AuditRestrictions.eq("reference", new SetRefEdMulIdEntity(id3, null)))
+                .add(AuditEntity.property("reference").eq(new SetRefEdMulIdEntity(id3, null)))
                 .getResultList());
 
         assert rev1.equals(rev1_related);
@@ -147,17 +147,17 @@
     public void testEntitiesReferencedToId4() {
         Set rev1_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id4))
+                .add(AuditEntity.relatedId("reference").eq(id4))
                 .getResultList());
 
         Set rev2_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id4))
+                .add(AuditEntity.relatedId("reference").eq(id4))
                 .getResultList());
 
         Set rev3_related = new HashSet(getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id4))
+                .add(AuditEntity.relatedId("reference").eq(id4))
                 .getResultList());
 
         assert rev1_related.equals(TestTools.makeSet());
@@ -169,20 +169,20 @@
     public void testEntitiesReferencedByIng1ToId3() {
         List rev1_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id1))
                 .getResultList();
 
         Object rev2_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id1))
                 .getSingleResult();
 
         Object rev3_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id1))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id1))
                 .getSingleResult();
 
         assert rev1_related.size() == 0;
@@ -194,20 +194,20 @@
     public void testEntitiesReferencedByIng2ToId3() {
         List rev1_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id2))
                 .getResultList();
 
         List rev2_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id2))
                 .getResultList();
 
         Object rev3_related = getAuditReader().createQuery()
                 .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
-                .add(AuditRestrictions.relatedIdEq("reference", id3))
-                .add(AuditRestrictions.idEq(id2))
+                .add(AuditEntity.relatedId("reference").eq(id3))
+                .add(AuditEntity.id().eq(id2))
                 .getSingleResult();
 
         assert rev1_related.size() == 0;




More information about the hibernate-commits mailing list