Hibernate SVN: r20720 - in validator/trunk: hibernate-validator and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-09-27 08:21:21 -0400 (Mon, 27 Sep 2010)
New Revision: 20720
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
validator/trunk/pom.xml
Log:
HV-378 Updated pom variables. Also finally found the right syntax for the testng package syntax
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2010-09-27 11:30:37 UTC (rev 20719)
+++ validator/trunk/hibernate-validator/pom.xml 2010-09-27 12:21:21 UTC (rev 20720)
@@ -154,7 +154,7 @@
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
- <manifestFile>${pom.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
@@ -172,10 +172,10 @@
org.slf4j.*;version="[1.5.6,2.0.0)"
</Import-Package>
<Export-Package>
- org.hibernate.validator;version="${pom.version}",
- org.hibernate.validator.constraints;version="${pom.version}",
- org.hibernate.validator.messageinterpolation;version="${pom.version}",
- org.hibernate.validator.resourceloading;version="${pom.version}",
+ org.hibernate.validator;version="${project.version}",
+ org.hibernate.validator.constraints;version="${project.version}",
+ org.hibernate.validator.messageinterpolation;version="${project.version}",
+ org.hibernate.validator.resourceloading;version="${project.version}",
</Export-Package>
</instructions>
</configuration>
@@ -244,7 +244,7 @@
<doctitle>Hibernate Validator ${project.version}</doctitle>
<windowtitle>Hibernate Validator ${project.version}</windowtitle>
<bottom>
- <![CDATA[Copyright © ${inceptionYear}-{currentYear} <a href="http://redhat.com">Red Hat Middleware, LLC.</a> All Rights Reserved]]></bottom>
+ <![CDATA[Copyright © ${project.inceptionYear}-{currentYear} <a href="http://redhat.com">Red Hat Middleware, LLC.</a> All Rights Reserved]]></bottom>
</configuration>
</plugin>
<plugin>
@@ -342,12 +342,4 @@
</plugin>
</plugins>
</build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
</project>
Modified: validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2010-09-27 11:30:37 UTC (rev 20719)
+++ validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2010-09-27 12:21:21 UTC (rev 20720)
@@ -3,25 +3,7 @@
<suite name="Hibernate Validator Unit Tests" verbose="1">
<test name="Unit tests">
<packages>
- <package name="org.hibernate.validator.test"/>
- <package name="org.hibernate.validator.test.bootstrap"/>
- <package name="org.hibernate.validator.test.cfg"/>
- <package name="org.hibernate.validator.test.constraints"/>
- <package name="org.hibernate.validator.test.constraints.impl"/>
- <package name="org.hibernate.validator.test.constraints.composition"/>
- <package name="org.hibernate.validator.test.engine"/>
- <package name="org.hibernate.validator.test.engine.customerror"/>
- <package name="org.hibernate.validator.test.engine.groups"/>
- <package name="org.hibernate.validator.test.engine.messageinterpolation"/>
- <package name="org.hibernate.validator.test.engine.proxy"/>
- <package name="org.hibernate.validator.test.engine.serialization"/>
- <package name="org.hibernate.validator.test.engine.traversableresolver"/>
- <package name="org.hibernate.validator.test.metadata"/>
- <package name="org.hibernate.validator.test.resourceloading"/>
- <package name="org.hibernate.validator.test.util"/>
- <package name="org.hibernate.validator.test.util.annotationfactory"/>
- <package name="org.hibernate.validator.test.xml"/>
- <package name="org.hibernate.validator.test.xml.mixedconfiguration"/>
+ <package name="org.hibernate.validator.test.*"/>
</packages>
</test>
-</suite>
\ No newline at end of file
+</suite>
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2010-09-27 11:30:37 UTC (rev 20719)
+++ validator/trunk/pom.xml 2010-09-27 12:21:21 UTC (rev 20720)
@@ -56,7 +56,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
- <version>${version}</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
@@ -345,43 +345,4 @@
<url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.0.1</version>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jxr-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-clover-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>taglist-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>changelog-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>changes-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
</project>
14 years, 12 months
Hibernate SVN: r20719 - in jpamodelgen/trunk/src: main/java/org/hibernate/jpamodelgen/util and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-09-27 07:30:37 -0400 (Mon, 27 Sep 2010)
New Revision: 20719
Added:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java
Log:
METAGEN-38 Added support for Blob and a corresponding test.
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2010-09-26 19:56:28 UTC (rev 20718)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -413,7 +413,7 @@
return Boolean.TRUE;
}
- if ( ElementKind.CLASS.equals( element.getKind() ) ) {
+ if ( ElementKind.CLASS.equals( element.getKind() ) || ElementKind.INTERFACE.equals( element.getKind() )) {
TypeElement typeElement = ( ( TypeElement ) element );
String typeName = typeElement.getQualifiedName().toString();
if ( Constants.BASIC_TYPES.contains( typeName ) ) {
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java 2010-09-26 19:56:28 UTC (rev 20718)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
@@ -29,38 +29,41 @@
public static Map<String, String> COLLECTIONS = new HashMap<String, String>();
static {
- COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.CollectionAttribute" );
- COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttribute" );
- COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttribute" );
- COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttribute" );
+ COLLECTIONS.put(
+ java.util.Collection.class.getName(), javax.persistence.metamodel.CollectionAttribute.class.getName()
+ );
+ COLLECTIONS.put( java.util.Set.class.getName(), javax.persistence.metamodel.SetAttribute.class.getName() );
+ COLLECTIONS.put( java.util.List.class.getName(), javax.persistence.metamodel.ListAttribute.class.getName() );
+ COLLECTIONS.put( java.util.Map.class.getName(), javax.persistence.metamodel.MapAttribute.class.getName() );
}
public static List<String> BASIC_TYPES = new ArrayList<String>();
static {
- BASIC_TYPES.add( "java.lang.String" );
- BASIC_TYPES.add( "java.lang.Boolean" );
- BASIC_TYPES.add( "java.lang.Byte" );
- BASIC_TYPES.add( "java.lang.Character" );
- BASIC_TYPES.add( "java.lang.Short" );
- BASIC_TYPES.add( "java.lang.Integer" );
- BASIC_TYPES.add( "java.lang.Long" );
- BASIC_TYPES.add( "java.lang.Float" );
- BASIC_TYPES.add( "java.lang.Double" );
- BASIC_TYPES.add( "java.math.BigInteger" );
- BASIC_TYPES.add( "java.math.BigDecimal" );
- BASIC_TYPES.add( "java.util.Date" );
- BASIC_TYPES.add( "java.util.Calendar" );
- BASIC_TYPES.add( "java.sql.Date" );
- BASIC_TYPES.add( "java.sql.Time" );
- BASIC_TYPES.add( "java.sql.Timestamp" );
+ BASIC_TYPES.add( java.lang.String.class.getName() );
+ BASIC_TYPES.add( java.lang.Boolean.class.getName() );
+ BASIC_TYPES.add( java.lang.Byte.class.getName() );
+ BASIC_TYPES.add( java.lang.Character.class.getName() );
+ BASIC_TYPES.add( java.lang.Short.class.getName() );
+ BASIC_TYPES.add( java.lang.Integer.class.getName() );
+ BASIC_TYPES.add( java.lang.Long.class.getName() );
+ BASIC_TYPES.add( java.lang.Float.class.getName() );
+ BASIC_TYPES.add( java.lang.Double.class.getName() );
+ BASIC_TYPES.add( java.math.BigInteger.class.getName() );
+ BASIC_TYPES.add( java.math.BigDecimal.class.getName() );
+ BASIC_TYPES.add( java.util.Date.class.getName() );
+ BASIC_TYPES.add( java.util.Calendar.class.getName() );
+ BASIC_TYPES.add( java.sql.Date.class.getName() );
+ BASIC_TYPES.add( java.sql.Time.class.getName() );
+ BASIC_TYPES.add( java.sql.Timestamp.class.getName() );
+ BASIC_TYPES.add( java.sql.Blob.class.getName() );
}
public static List<String> BASIC_ARRAY_TYPES = new ArrayList<String>();
static {
- BASIC_ARRAY_TYPES.add( "java.lang.Character" );
- BASIC_ARRAY_TYPES.add( "java.lang.Byte" );
+ BASIC_ARRAY_TYPES.add( java.lang.Character.class.getName() );
+ BASIC_ARRAY_TYPES.add( java.lang.Byte.class.getName() );
}
public static final String PATH_SEPARATOR = "/";
Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -0,0 +1,39 @@
+// $Id: User.java 17903 2009-11-04 13:22:37Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.blob;
+
+import java.sql.Blob;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+@Table
+public class BlobEntity {
+ @Id
+ private String id;
+
+ @Lob
+ private Blob blob;
+}
+
+
Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java (from rev 20692, jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementcollection/ElementCollectionTest.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -0,0 +1,44 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.blob;
+
+import org.testng.annotations.Test;
+
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class BlobTest extends CompilationTest {
+ /**
+ * METAGEN-38
+ */
+ @Test
+ public void testBlobField() {
+ assertMetamodelClassGeneratedFor( BlobEntity.class );
+ assertPresenceOfFieldInMetamodelFor( BlobEntity.class, "blob", "the metamodel should have a member 'blob'" );
+ }
+
+ @Override
+ protected String getPackageNameOfTestSources() {
+ return BlobTest.class.getPackage().getName();
+ }
+}
\ No newline at end of file
14 years, 12 months
Hibernate SVN: r20718 - core/trunk/documentation/envers/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: fbascheper
Date: 2010-09-26 15:56:28 -0400 (Sun, 26 Sep 2010)
New Revision: 20718
Modified:
core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml
Log:
HHH-5560 - Rename Envers ValidAuditTimeStrategy to ValidityAuditStrategy
Modified: core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml
===================================================================
--- core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml 2010-09-26 19:55:50 UTC (rev 20717)
+++ core/trunk/documentation/envers/src/main/docbook/en-US/content/configuration.xml 2010-09-26 19:56:28 UTC (rev 20718)
@@ -30,21 +30,66 @@
<chapter id="configuration">
- <title>Configuration</title>
+ <title>Configuration</title>
- <para>
+ <section id="config-basics">
+ <title>Basic configuration</title>
+
+ <para>
To start working with Envers, all configuration that you must do is add the event
listeners to persistence.xml, as described in the <xref linkend="quickstart"/>.
- </para>
+ </para>
- <para>
+ <para>
However, as Envers generates some entities, and maps them to tables, it is possible to set the prefix and suffix
that is added to the entity name to create an audit table for an entity, as well
as set the names of the fields that are generated.
- </para>
+ </para>
+ </section>
+
+ <section id="config-audit-strategy">
+
+ <title>Choosing an audit strategy</title>
+
+ <para>
+ After the basic configuration it is important to choose the audit strategy that will be used to persist and
+ retrieve audit information. There is a trade-off is between the performance of persisting and the performance
+ of querying the audit information. Currently there two audit strategies:
+
+ <orderedlist>
+ <listitem>
+ <para>
+ The default audit strategy persists the audit data together with a start revision. For each row
+ inserted, updated or deleted in an audited table, one or more rows are inserted in the audit tables,
+ together with the start revision of its validity. Rows in the audit tables are never updated after insertion.
+ Queries of audit information use subqueries to select the applicable rows in the audit tables.
+ These subqueries are notoriously slow and difficult to index.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The alternative is a validity audit strategy. This strategy stores the start-revision and the end-revision
+ of audit information. For each row inserted, updated or deleted in an audited table, one or more rows
+ are inserted in the audit tables, together with the start revision of its validity. But at the same time
+ the end-revision field of the previous audit rows (if available) are set to this revision.
+ Queries on the audit information can then use 'between start and end revision' instead of subqueries
+ as used by the default audit strategy.
+ The consequence of this strategy is that persisting audit information will be a bit slower, because of the
+ extra updates involved, but retrieving audit information will be a lot faster. This can be improved by
+ adding extra indexes.
+ </para>
+ </listitem>
+ </orderedlist>
+ </para>
+
+ </section>
+
+ <section id="config-reference">
+ <title>Reference</title>
+
<para>
- In more detail, here are the properites that you can set:
+ In more detail, here are the properties that you can set:
</para>
<table frame="topbot">
@@ -186,21 +231,22 @@
</entry>
<entry>
The audit strategy that should be used when persisting audit data. The default stores only the
- revision, at which an entity was modified. An alternative,
- <literal>org.hibernate.envers.strategy.ValidTimeAuditStrategy</literal> stores additionaly the
- end revision, until which the data was valid.
+ revision, at which an entity was modified. An alternative, the
+ <literal>org.hibernate.envers.strategy.ValidityAuditStrategy</literal> stores both the
+ start revision and the end revision. Together these define when an audit row was valid, hence
+ the name ValidityAuditStrategy.
</entry>
</row>
<row>
<entry>
- <property>org.hibernate.envers.audit_strategy_valid_time_end_name</property>
+ <property>org.hibernate.envers.audit_strategy_validity_end_rev_field_name</property>
</entry>
<entry>
REVEND
</entry>
<entry>
- Only valid if the audit strategy is valid-time. Name of the column that will hold the end
- revision number in audit entities.
+ The column name that will hold the end revision number in audit entities. This property is only
+ valid if the validity audit strategy is used.
</entry>
</row>
</tbody>
@@ -280,4 +326,7 @@
<literal>@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)</literal>. Then, when reading historic
versions of your entity, the relation will always point to the "current" related entity.
</para>
+
+ </section>
+
</chapter>
15 years
Hibernate SVN: r20717 - in core/trunk/envers/src: main/java/org/hibernate/envers/configuration/metadata and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: fbascheper
Date: 2010-09-26 15:55:50 -0400 (Sun, 26 Sep 2010)
New Revision: 20717
Added:
core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.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/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/TwoEntityOneAuditedQueryGenerator.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/impl/EntitiesAtRevisionQuery.java
core/trunk/envers/src/main/java/org/hibernate/envers/strategy/AuditStrategy.java
core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidTimeAuditStrategy.java
core/trunk/envers/src/test/resources/hibernate.test.cfg.xml
core/trunk/envers/src/test/resources/testng.xml
Log:
HHH-5560 - Rename Envers ValidAuditTimeStrategy to ValidityAuditTimeStrategy
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 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/AuditEntitiesConfiguration.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -35,7 +35,7 @@
import org.hibernate.MappingException;
import org.hibernate.envers.strategy.DefaultAuditStrategy;
-import org.hibernate.envers.strategy.ValidTimeAuditStrategy;
+import org.hibernate.envers.strategy.ValidityAuditStrategy;
/**
* Configuration of versions entities - names of fields, entities and tables created to store versioning information.
@@ -93,8 +93,8 @@
revisionTypePropType = "byte";
revisionEndFieldName = getProperty(properties,
+ "org.hibernate.envers.audit_strategy_validity_end_rev_field_name",
"org.hibernate.envers.audit_strategy_valid_time_end_name",
- "org.hibernate.envers.audit_strategy_valid_time_end_name",
"REVEND");
customAuditTablesNames = new HashMap<String, String>();
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 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -28,9 +28,11 @@
import java.util.Map;
import org.dom4j.Element;
-import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.envers.RelationTargetAuditMode;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.configuration.GlobalConfiguration;
-import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
import org.hibernate.envers.configuration.metadata.reader.ClassAuditingData;
import org.hibernate.envers.configuration.metadata.reader.PropertyAuditingData;
import org.hibernate.envers.entities.EntityConfiguration;
@@ -40,15 +42,20 @@
import org.hibernate.envers.entities.mapper.MultiPropertyMapper;
import org.hibernate.envers.entities.mapper.SubclassPropertyMapper;
import org.hibernate.envers.strategy.AuditStrategy;
-import org.hibernate.envers.strategy.ValidTimeAuditStrategy;
+import org.hibernate.envers.strategy.ValidityAuditStrategy;
import org.hibernate.envers.tools.StringTools;
import org.hibernate.envers.tools.Triple;
-import org.hibernate.envers.RelationTargetAuditMode;
-
-import org.hibernate.MappingException;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.mapping.*;
-import org.hibernate.type.*;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Table;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.CollectionType;
+import org.hibernate.type.ComponentType;
+import org.hibernate.type.ManyToOneType;
+import org.hibernate.type.OneToOneType;
+import org.hibernate.type.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -139,7 +146,7 @@
private void addEndRevision(Element any_mapping) {
// Add the end-revision field, if the appropriate strategy is used.
- if (ValidTimeAuditStrategy.class.getName().equals(verEntCfg.getAuditStrategyName())) {
+ if (auditStrategy instanceof ValidityAuditStrategy) {
Element end_rev_mapping = (Element) revisionInfoRelationMapping.clone();
end_rev_mapping.setName("many-to-one");
end_rev_mapping.addAttribute("name", verEntCfg.getRevisionEndFieldName());
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 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -61,7 +61,7 @@
* e.revision = (SELECT max(e2.revision) FROM versionsReferencedEntity e2
* WHERE e2.revision <= :revision AND e2.id = e.id)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)
*
* AND
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 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -62,7 +62,7 @@
* ee.revision = (SELECT max(ee2.revision) FROM middleEntity ee2
* WHERE ee2.revision <= :revision AND ee2.originalId.* = ee.originalId.*)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* ee.revision <= :revision and (ee.endRevision > :revision or ee.endRevision is null)
*
* AND
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 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/ThreeEntityQueryGenerator.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -70,7 +70,7 @@
* e.revision = (SELECT max(e2.revision) FROM versionsReferencedEntity e2
* WHERE e2.revision <= :revision AND e2.id = e.id)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)
*
* AND
@@ -80,7 +80,7 @@
* f.revision = (SELECT max(f2.revision) FROM versionsIndexEntity f2
* WHERE f2.revision <= :revision AND f2.id_ref_ed = f.id_ref_ed)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* f.revision <= :revision and (f.endRevision > :revision or f.endRevision is null)
*
* AND
@@ -90,7 +90,7 @@
* ee.revision = (SELECT max(ee2.revision) FROM middleEntity ee2
* WHERE ee2.revision <= :revision AND ee2.originalId.* = ee.originalId.*)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* ee.revision <= :revision and (ee.endRevision > :revision or ee.endRevision is null)
*
and (
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityOneAuditedQueryGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityOneAuditedQueryGenerator.java 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityOneAuditedQueryGenerator.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -68,7 +68,7 @@
* ee.revision = (SELECT max(ee2.revision) FROM middleEntity ee2
* WHERE ee2.revision <= :revision AND ee2.originalId.* = ee.originalId.*)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* ee.revision <= :revision and (ee.endRevision > :revision or ee.endRevision is null)
*
* AND
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 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/TwoEntityQueryGenerator.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -68,7 +68,7 @@
* e.revision = (SELECT max(e2.revision) FROM versionsReferencedEntity e2
* WHERE e2.revision <= :revision AND e2.id = e.id)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)
*
* AND
@@ -78,7 +78,7 @@
* ee.revision = (SELECT max(ee2.revision) FROM middleEntity ee2
* WHERE ee2.revision <= :revision AND ee2.originalId.* = ee.originalId.*)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* ee.revision <= :revision and (ee.endRevision > :revision or ee.endRevision is null)
*
* (only non-deleted entities and associations)
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 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/query/impl/EntitiesAtRevisionQuery.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -67,7 +67,7 @@
* e.revision = (SELECT max(e2.revision) FROM versionsReferencedEntity e2
* WHERE e2.revision <= :revision AND e2.id = e.id)
*
- * --> for ValidTimeAuditStrategy:
+ * --> for ValidityAuditStrategy:
* e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)
*
* AND
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/strategy/AuditStrategy.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/strategy/AuditStrategy.java 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/strategy/AuditStrategy.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -49,7 +49,7 @@
* <li>For {@link DefaultAuditStrategy} a subquery is created:
* <p><code>e.revision = (SELECT max(...) ...)</code></p>
* </li>
- * <li>for {@link ValidTimeAuditStrategy} the revision-end column is used:
+ * <li>for {@link ValidityAuditStrategy} the revision-end column is used:
* <p><code>e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)</code></p>
* </li>
* </ul>
@@ -57,13 +57,13 @@
* @param globalCfg the {@link GlobalConfiguration}
* @param rootQueryBuilder the {@link QueryBuilder} that will be updated
* @param revisionProperty property of the revision column
- * @param revisionEndProperty property of the revisionEnd column (only used for {@link ValidTimeAuditStrategy})
+ * @param revisionEndProperty property of the revisionEnd column (only used for {@link ValidityAuditStrategy})
* @param addAlias {@code boolean} indicator if a left alias is needed
* @param idData id-information for the two-entity relation (only used for {@link DefaultAuditStrategy})
- * @param revisionPropertyPath path of the revision property (only used for {@link ValidTimeAuditStrategy})
- * @param originalIdPropertyName name of the id property (only used for {@link ValidTimeAuditStrategy})
- * @param alias1 an alias used for subquery (only used for {@link ValidTimeAuditStrategy})
- * @param alias2 an alias used for subquery (only used for {@link ValidTimeAuditStrategy})
+ * @param revisionPropertyPath path of the revision property (only used for {@link ValidityAuditStrategy})
+ * @param originalIdPropertyName name of the id property (only used for {@link ValidityAuditStrategy})
+ * @param alias1 an alias used for subquery (only used for {@link ValidityAuditStrategy})
+ * @param alias2 an alias used for subquery (only used for {@link ValidityAuditStrategy})
*/
void addEntityAtRevisionRestriction(GlobalConfiguration globalCfg, QueryBuilder rootQueryBuilder,
String revisionProperty, String revisionEndProperty, boolean addAlias, MiddleIdData idData,
@@ -76,20 +76,20 @@
* <li>For {@link DefaultAuditStrategy} a subquery is created:
* <p><code>e.revision = (SELECT max(...) ...)</code></p>
* </li>
- * <li>for {@link ValidTimeAuditStrategy} the revision-end column is used:
+ * <li>for {@link ValidityAuditStrategy} the revision-end column is used:
* <p><code>e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)</code></p>
* </li>
* </ul>
*
* @param rootQueryBuilder the {@link QueryBuilder} that will be updated
* @param revisionProperty property of the revision column
- * @param revisionEndProperty property of the revisionEnd column (only used for {@link ValidTimeAuditStrategy})
+ * @param revisionEndProperty property of the revisionEnd column (only used for {@link ValidityAuditStrategy})
* @param addAlias {@code boolean} indicator if a left alias is needed
* @param referencingIdData id-information for the middle-entity association (only used for {@link DefaultAuditStrategy})
* @param versionsMiddleEntityName name of the middle-entity
- * @param eeOriginalIdPropertyPath name of the id property (only used for {@link ValidTimeAuditStrategy})
- * @param revisionPropertyPath path of the revision property (only used for {@link ValidTimeAuditStrategy})
- * @param originalIdPropertyName name of the id property (only used for {@link ValidTimeAuditStrategy})
+ * @param eeOriginalIdPropertyPath name of the id property (only used for {@link ValidityAuditStrategy})
+ * @param revisionPropertyPath path of the revision property (only used for {@link ValidityAuditStrategy})
+ * @param originalIdPropertyName name of the id property (only used for {@link ValidityAuditStrategy})
* @param componentDatas information about the middle-entity relation
*/
void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder, String revisionProperty,
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidTimeAuditStrategy.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidTimeAuditStrategy.java 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidTimeAuditStrategy.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -1,135 +1,25 @@
package org.hibernate.envers.strategy;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import org.hibernate.Session;
-import org.hibernate.envers.RevisionType;
-import org.hibernate.envers.configuration.AuditConfiguration;
-import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
-import org.hibernate.envers.configuration.GlobalConfiguration;
-import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
-import org.hibernate.envers.entities.mapper.id.IdMapper;
-import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
-import org.hibernate.envers.entities.mapper.relation.MiddleIdData;
-import org.hibernate.envers.tools.query.Parameters;
-import org.hibernate.envers.tools.query.QueryBuilder;
-
/**
- * Audit strategy which additionally manages the end-revision number: updates the end-revision field on the last
- * revision that was persisted before the current one.
+ * Deprecated Audit strategy class.
*
* @author Stephanie Pau
* @author Adam Warski (adam at warski dot org)
+ *
+ * @deprecated use {@link ValidityAuditStrategy} instead.
*/
-public class ValidTimeAuditStrategy implements AuditStrategy {
- public void perform(Session session, String entityName, AuditConfiguration auditCfg, Serializable id, Object data,
- Object revision) {
- AuditEntitiesConfiguration audEntCfg = auditCfg.getAuditEntCfg();
- String auditedEntityName = audEntCfg.getAuditEntityName(entityName);
+public class ValidTimeAuditStrategy extends ValidityAuditStrategy {
- // Update the end date of the previous row if this operation is expected to have a previous row
- if (getRevisionType(auditCfg, data) != RevisionType.ADD) {
- /*
- Constructing a query:
- select e from audited_ent e where e.end_rev is null and e.id = :id
- */
+ private final Logger log = LoggerFactory.getLogger(ValidTimeAuditStrategy.class);
- QueryBuilder qb = new QueryBuilder(auditedEntityName, "e");
-
- // e.id = :id
- IdMapper idMapper = auditCfg.getEntCfg().get(entityName).getIdMapper();
- idMapper.addIdEqualsToQuery(qb.getRootParameters(), id, auditCfg.getAuditEntCfg().getOriginalIdPropName(), true);
-
- updateLastRevision(session, auditCfg, qb, id, auditedEntityName, revision);
- }
-
- // Save the audit data
- session.save(auditedEntityName, data);
- }
-
- @SuppressWarnings({"unchecked"})
- public void performCollectionChange(Session session, AuditConfiguration auditCfg,
- PersistentCollectionChangeData persistentCollectionChangeData, Object revision) {
- // Update the end date of the previous row if this operation is expected to have a previous row
- if (getRevisionType(auditCfg, persistentCollectionChangeData.getData()) != RevisionType.ADD) {
- /*
- Constructing a query (there are multiple id fields):
- select e from audited_middle_ent e where e.end_rev is null and e.id1 = :id1 and e.id2 = :id2 ...
- */
-
- QueryBuilder qb = new QueryBuilder(persistentCollectionChangeData.getEntityName(), "e");
-
- // Adding a parameter for each id component, except the rev number
- String originalIdPropName = auditCfg.getAuditEntCfg().getOriginalIdPropName();
- Map<String, Object> originalId = (Map<String, Object>) persistentCollectionChangeData.getData().get(
- originalIdPropName);
- for (Map.Entry<String, Object> originalIdEntry : originalId.entrySet()) {
- if (!auditCfg.getAuditEntCfg().getRevisionFieldName().equals(originalIdEntry.getKey())) {
- qb.getRootParameters().addWhereWithParam(originalIdPropName + "." + originalIdEntry.getKey(),
- true, "=", originalIdEntry.getValue());
- }
- }
-
- updateLastRevision(session, auditCfg, qb, originalId, persistentCollectionChangeData.getEntityName(), revision);
- }
-
- // Save the audit data
- session.save(persistentCollectionChangeData.getEntityName(), persistentCollectionChangeData.getData());
- }
-
- public void addEntityAtRevisionRestriction(GlobalConfiguration globalCfg, QueryBuilder rootQueryBuilder,
- String revisionProperty,String revisionEndProperty, boolean addAlias,
- MiddleIdData idData, String revisionPropertyPath, String originalIdPropertyName,
- String alias1, String alias2) {
- Parameters rootParameters = rootQueryBuilder.getRootParameters();
- addRevisionRestriction(rootParameters, revisionProperty, revisionEndProperty, addAlias);
+ /**
+ * Default constructor. Log a warn message that this class is deprecated.
+ */
+ public ValidTimeAuditStrategy() {
+ log.warn("ValidTimeAuditStrategy is deprecated, please use ValidityAuditStrategy instead");
}
-
- public void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder, String revisionProperty,
- String revisionEndProperty, boolean addAlias, MiddleIdData referencingIdData,
- String versionsMiddleEntityName, String eeOriginalIdPropertyPath, String revisionPropertyPath,
- String originalIdPropertyName, MiddleComponentData... componentDatas) {
- Parameters rootParameters = rootQueryBuilder.getRootParameters();
- addRevisionRestriction(rootParameters, revisionProperty, revisionEndProperty, addAlias);
- }
-
- private void addRevisionRestriction(Parameters rootParameters,
- String revisionProperty, String revisionEndProperty, boolean addAlias) {
-
- // e.revision <= _revision and (e.endRevision > _revision or e.endRevision is null)
- Parameters subParm = rootParameters.addSubParameters("or");
- rootParameters.addWhereWithNamedParam(revisionProperty, addAlias, "<=", "revision");
- subParm.addWhereWithNamedParam(revisionEndProperty + ".id", addAlias, ">", "revision");
- subParm.addWhere(revisionEndProperty, addAlias, "is", "null", false);
- }
- @SuppressWarnings({"unchecked"})
- private RevisionType getRevisionType(AuditConfiguration auditCfg, Object data) {
- return (RevisionType) ((Map<String, Object>) data).get(auditCfg.getAuditEntCfg().getRevisionTypePropName());
- }
-
- @SuppressWarnings({"unchecked"})
- private void updateLastRevision(Session session, AuditConfiguration auditCfg, QueryBuilder qb,
- Object id, String auditedEntityName, Object revision) {
- String revisionEndFieldName = auditCfg.getAuditEntCfg().getRevisionEndFieldName();
-
- // e.end_rev is null
- qb.getRootParameters().addWhere(revisionEndFieldName, true, "is", "null", false);
-
- List l = qb.toQuery(session).list();
-
- // There should be one entry
- if (l.size() == 1) {
- // Setting the end revision to be the current rev
- Object previousData = l.get(0);
- ((Map<String, Object>) previousData).put(revisionEndFieldName, revision);
-
- // Saving the previous version
- session.save(auditedEntityName, previousData);
- } else {
- throw new RuntimeException("Cannot find previous revision for entity " + auditedEntityName + " and id " + id);
- }
- }
}
Added: core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java 2010-09-26 19:55:50 UTC (rev 20717)
@@ -0,0 +1,150 @@
+package org.hibernate.envers.strategy;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.Session;
+import org.hibernate.envers.RevisionType;
+import org.hibernate.envers.configuration.AuditConfiguration;
+import org.hibernate.envers.configuration.AuditEntitiesConfiguration;
+import org.hibernate.envers.configuration.GlobalConfiguration;
+import org.hibernate.envers.entities.mapper.PersistentCollectionChangeData;
+import org.hibernate.envers.entities.mapper.id.IdMapper;
+import org.hibernate.envers.entities.mapper.relation.MiddleComponentData;
+import org.hibernate.envers.entities.mapper.relation.MiddleIdData;
+import org.hibernate.envers.tools.query.Parameters;
+import org.hibernate.envers.tools.query.QueryBuilder;
+
+/**
+ * Audit strategy which persists and retrieves audit information using a validity algorithm, based on the
+ * start-revision and end-revision of a row in the audit tables.
+ * <p>This algorithm works as follows:
+ * <ul>
+ * <li>For a <strong>new row</strong> that is persisted in an audit table, only the <strong>start-revision</strong> column of that row is set</li>
+ * <li>At the same time the <strong>end-revision</strong> field of the <strong>previous</strong> audit row is set to this revision</li>
+ * <li>Queries are retrieved using 'between start and end revision', instead of a subquery.</li>
+ * </ul>
+ * </p>
+ *
+ * <p>
+ * This has a few important consequences that need to be judged against against each other:
+ * <ul>
+ * <li>Persisting audit information is a bit slower, because an extra row is updated</li>
+ * <li>Retrieving audit information is a lot faster</li>
+ * </ul>
+ * </p>
+ *
+ * @author Stephanie Pau
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class ValidityAuditStrategy implements AuditStrategy {
+ public void perform(Session session, String entityName, AuditConfiguration auditCfg, Serializable id, Object data,
+ Object revision) {
+ AuditEntitiesConfiguration audEntCfg = auditCfg.getAuditEntCfg();
+ String auditedEntityName = audEntCfg.getAuditEntityName(entityName);
+
+ // Update the end date of the previous row if this operation is expected to have a previous row
+ if (getRevisionType(auditCfg, data) != RevisionType.ADD) {
+ /*
+ Constructing a query:
+ select e from audited_ent e where e.end_rev is null and e.id = :id
+ */
+
+ QueryBuilder qb = new QueryBuilder(auditedEntityName, "e");
+
+ // e.id = :id
+ IdMapper idMapper = auditCfg.getEntCfg().get(entityName).getIdMapper();
+ idMapper.addIdEqualsToQuery(qb.getRootParameters(), id, auditCfg.getAuditEntCfg().getOriginalIdPropName(), true);
+
+ updateLastRevision(session, auditCfg, qb, id, auditedEntityName, revision);
+ }
+
+ // Save the audit data
+ session.save(auditedEntityName, data);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void performCollectionChange(Session session, AuditConfiguration auditCfg,
+ PersistentCollectionChangeData persistentCollectionChangeData, Object revision) {
+ // Update the end date of the previous row if this operation is expected to have a previous row
+ if (getRevisionType(auditCfg, persistentCollectionChangeData.getData()) != RevisionType.ADD) {
+ /*
+ Constructing a query (there are multiple id fields):
+ select e from audited_middle_ent e where e.end_rev is null and e.id1 = :id1 and e.id2 = :id2 ...
+ */
+
+ QueryBuilder qb = new QueryBuilder(persistentCollectionChangeData.getEntityName(), "e");
+
+ // Adding a parameter for each id component, except the rev number
+ String originalIdPropName = auditCfg.getAuditEntCfg().getOriginalIdPropName();
+ Map<String, Object> originalId = (Map<String, Object>) persistentCollectionChangeData.getData().get(
+ originalIdPropName);
+ for (Map.Entry<String, Object> originalIdEntry : originalId.entrySet()) {
+ if (!auditCfg.getAuditEntCfg().getRevisionFieldName().equals(originalIdEntry.getKey())) {
+ qb.getRootParameters().addWhereWithParam(originalIdPropName + "." + originalIdEntry.getKey(),
+ true, "=", originalIdEntry.getValue());
+ }
+ }
+
+ updateLastRevision(session, auditCfg, qb, originalId, persistentCollectionChangeData.getEntityName(), revision);
+ }
+
+ // Save the audit data
+ session.save(persistentCollectionChangeData.getEntityName(), persistentCollectionChangeData.getData());
+ }
+
+ public void addEntityAtRevisionRestriction(GlobalConfiguration globalCfg, QueryBuilder rootQueryBuilder,
+ String revisionProperty,String revisionEndProperty, boolean addAlias,
+ MiddleIdData idData, String revisionPropertyPath, String originalIdPropertyName,
+ String alias1, String alias2) {
+ Parameters rootParameters = rootQueryBuilder.getRootParameters();
+ addRevisionRestriction(rootParameters, revisionProperty, revisionEndProperty, addAlias);
+ }
+
+ public void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder, String revisionProperty,
+ String revisionEndProperty, boolean addAlias, MiddleIdData referencingIdData,
+ String versionsMiddleEntityName, String eeOriginalIdPropertyPath, String revisionPropertyPath,
+ String originalIdPropertyName, MiddleComponentData... componentDatas) {
+ Parameters rootParameters = rootQueryBuilder.getRootParameters();
+ addRevisionRestriction(rootParameters, revisionProperty, revisionEndProperty, addAlias);
+ }
+
+ private void addRevisionRestriction(Parameters rootParameters,
+ String revisionProperty, String revisionEndProperty, boolean addAlias) {
+
+ // e.revision <= _revision and (e.endRevision > _revision or e.endRevision is null)
+ Parameters subParm = rootParameters.addSubParameters("or");
+ rootParameters.addWhereWithNamedParam(revisionProperty, addAlias, "<=", "revision");
+ subParm.addWhereWithNamedParam(revisionEndProperty + ".id", addAlias, ">", "revision");
+ subParm.addWhere(revisionEndProperty, addAlias, "is", "null", false);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private RevisionType getRevisionType(AuditConfiguration auditCfg, Object data) {
+ return (RevisionType) ((Map<String, Object>) data).get(auditCfg.getAuditEntCfg().getRevisionTypePropName());
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private void updateLastRevision(Session session, AuditConfiguration auditCfg, QueryBuilder qb,
+ Object id, String auditedEntityName, Object revision) {
+ String revisionEndFieldName = auditCfg.getAuditEntCfg().getRevisionEndFieldName();
+
+ // e.end_rev is null
+ qb.getRootParameters().addWhere(revisionEndFieldName, true, "is", "null", false);
+
+ List<Object> l = qb.toQuery(session).list();
+
+ // There should be one entry
+ if (l.size() == 1) {
+ // Setting the end revision to be the current rev
+ Object previousData = l.get(0);
+ ((Map<String, Object>) previousData).put(revisionEndFieldName, revision);
+
+ // Saving the previous version
+ session.save(auditedEntityName, previousData);
+ } else {
+ throw new RuntimeException("Cannot find previous revision for entity " + auditedEntityName + " and id " + id);
+ }
+ }
+}
Modified: core/trunk/envers/src/test/resources/hibernate.test.cfg.xml
===================================================================
--- core/trunk/envers/src/test/resources/hibernate.test.cfg.xml 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/test/resources/hibernate.test.cfg.xml 2010-09-26 19:55:50 UTC (rev 20717)
@@ -23,7 +23,7 @@
<!--<property name="connection.username">root</property>-->
<!--<property name="connection.password"></property>-->
- <!--<property name="org.hibernate.envers.audit_strategy">org.hibernate.envers.strategy.ValidTimeAuditStrategy</property>-->
+ <!--<property name="org.hibernate.envers.audit_strategy">org.hibernate.envers.strategy.ValidityAuditStrategy</property>-->
<!--<property name="hibernate.jdbc.batch_size">100</property>-->
Modified: core/trunk/envers/src/test/resources/testng.xml
===================================================================
--- core/trunk/envers/src/test/resources/testng.xml 2010-09-26 19:12:41 UTC (rev 20716)
+++ core/trunk/envers/src/test/resources/testng.xml 2010-09-26 19:55:50 UTC (rev 20717)
@@ -84,8 +84,8 @@
&packages;
</packages>
</test>
- <test name="ValidTimeAuditStrategy">
- <parameter name="auditStrategy" value="org.hibernate.envers.strategy.ValidTimeAuditStrategy" />
+ <test name="ValidityAuditStrategy">
+ <parameter name="auditStrategy" value="org.hibernate.envers.strategy.ValidityAuditStrategy" />
<packages>
&packages;
</packages>
15 years
Hibernate SVN: r20716 - core/trunk/testsuite/src/test/java/org/hibernate/test/mixed.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-09-26 15:12:41 -0400 (Sun, 26 Sep 2010)
New Revision: 20716
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/mixed/MixedTest.java
Log:
HHH-5572 sybase does not support setBlob
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/mixed/MixedTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/mixed/MixedTest.java 2010-09-26 19:04:30 UTC (rev 20715)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/mixed/MixedTest.java 2010-09-26 19:12:41 UTC (rev 20716)
@@ -27,6 +27,8 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.testing.junit.functional.FunctionalTestCase;
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
@@ -51,6 +53,11 @@
return new FunctionalTestClassTestSuite( MixedTest.class );
}
+ @Override
+ public boolean appliesTo(Dialect dialect) {
+ return !(dialect instanceof SybaseASE15Dialect);
+ }
+
public void testMixedInheritance() {
Session s = openSession( new DocumentInterceptor() );
Transaction t = s.beginTransaction();
15 years
Hibernate SVN: r20715 - core/trunk/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-09-26 15:04:30 -0400 (Sun, 26 Sep 2010)
New Revision: 20715
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java
Log:
HHH-5572 sybase does not support setBlob
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java 2010-09-26 18:17:36 UTC (rev 20714)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java 2010-09-26 19:04:30 UTC (rev 20715)
@@ -537,7 +537,10 @@
}
public void testBlobClob() throws Exception {
-
+ // Sybase does not support ResultSet.getBlob(String)
+ if ( getDialect() instanceof SybaseDialect || getDialect() instanceof Sybase11Dialect || getDialect() instanceof SybaseASE15Dialect || getDialect() instanceof SybaseAnywhereDialect ) {
+ return;
+ }
Session s = openSession();
Blobber b = new Blobber();
b.setBlob( s.getLobHelper().createBlob( "foo/bar/baz".getBytes() ) );
@@ -547,13 +550,6 @@
//assertTrue( b.getClob() instanceof ClobImpl );
s.flush();
- // Sybase does not support ResultSet.getBlob(String)
- if ( getDialect() instanceof SybaseDialect || getDialect() instanceof Sybase11Dialect || getDialect() instanceof SybaseASE15Dialect || getDialect() instanceof SybaseAnywhereDialect ) {
- s.connection().rollback();
- s.close();
- return;
- }
-
s.refresh(b);
//b.getBlob().setBytes( 2, "abc".getBytes() );
b.getClob().getSubString(2, 3);
15 years
Hibernate SVN: r20714 - core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/query.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-09-26 14:17:36 -0400 (Sun, 26 Sep 2010)
New Revision: 20714
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java
Log:
correct non utf-8 character
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java 2010-09-26 18:10:52 UTC (rev 20713)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java 2010-09-26 18:17:36 UTC (rev 20714)
@@ -55,7 +55,7 @@
public void testParameterList() throws Exception {
final Item item = new Item( "Mouse", "Micro$oft mouse" );
- final Item item2 = new Item( "Computer", "D�ll computer" );
+ final Item item2 = new Item( "Computer", "Dell computer" );
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
@@ -127,7 +127,7 @@
public void testEscapeCharacter() throws Exception {
final Item item = new Item( "Mouse", "Micro_oft mouse" );
- final Item item2 = new Item( "Computer", "D�ll computer" );
+ final Item item2 = new Item( "Computer", "Dell computer" );
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
15 years
Hibernate SVN: r20713 - core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/subquery.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-09-26 14:10:52 -0400 (Sun, 26 Sep 2010)
New Revision: 20713
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/subquery/CorrelatedSubqueryTest.java
Log:
HHH-3032 Sybase restriction of using alias in sub-query
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/subquery/CorrelatedSubqueryTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/subquery/CorrelatedSubqueryTest.java 2010-09-26 16:47:04 UTC (rev 20712)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/subquery/CorrelatedSubqueryTest.java 2010-09-26 18:10:52 UTC (rev 20713)
@@ -32,6 +32,7 @@
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
+import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.ejb.metamodel.AbstractMetamodelSpecificTest;
import org.hibernate.ejb.metamodel.Customer;
import org.hibernate.ejb.metamodel.Customer_;
@@ -39,6 +40,7 @@
import org.hibernate.ejb.metamodel.LineItem_;
import org.hibernate.ejb.metamodel.Order;
import org.hibernate.ejb.metamodel.Order_;
+import org.hibernate.testing.junit.SkipForDialect;
/**
* TODO : javadoc
@@ -86,6 +88,7 @@
em.close();
}
+ @SkipForDialect(value=SybaseASE15Dialect.class, jiraKey="HHH-3032")
public void testCorrelationExplicitSelectionCorrelation() {
CriteriaBuilder builder = factory.getCriteriaBuilder();
EntityManager em = getOrCreateEntityManager();
15 years
Hibernate SVN: r20712 - core/trunk/parent.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-09-26 12:47:04 -0400 (Sun, 26 Sep 2010)
New Revision: 20712
Modified:
core/trunk/parent/pom.xml
Log:
HHH-5598 add sybase jdbc4 profile
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2010-09-26 15:42:11 UTC (rev 20711)
+++ core/trunk/parent/pom.xml 2010-09-26 16:47:04 UTC (rev 20712)
@@ -923,6 +923,25 @@
</properties>
</profile>
<profile>
+ <id>sybase15-jdbc4</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.sybase</groupId>
+ <artifactId>jconnect</artifactId>
+ <version>7.0.0_26502</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.SybaseASE15Dialect</db.dialect>
+ <jdbc.driver>com.sybase.jdbc4.jdbc.SybDriver</jdbc.driver>
+ <jdbc.url>jdbc:sybase:Tds:vmg07.mw.lab.eng.bos.redhat.com:5000/hibbrtru?SQLINITSTRING=set quoted_identifier on</jdbc.url>
+ <jdbc.user>hibbrtru</jdbc.user>
+ <jdbc.pass>hibbrtru</jdbc.pass>
+ <jdbc.isolation/>
+ </properties>
+ </profile>
+ <profile>
<id>sybase155</id>
<dependencies>
<dependency>
@@ -941,6 +960,25 @@
<jdbc.isolation/>
</properties>
</profile>
+ <profile>
+ <id>sybase155-jdbc4</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.sybase</groupId>
+ <artifactId>jconnect</artifactId>
+ <version>7.0.0_26502</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.SybaseASE15Dialect</db.dialect>
+ <jdbc.driver>com.sybase.jdbc4.jdbc.SybDriver</jdbc.driver>
+ <jdbc.url>jdbc:sybase:Tds:vmg09.mw.lab.eng.bos.redhat.com:5000/hibbrtru?SQLINITSTRING=set quoted_identifier on</jdbc.url>
+ <jdbc.user>hibbrtru</jdbc.user>
+ <jdbc.pass>hibbrtru</jdbc.pass>
+ <jdbc.isolation/>
+ </properties>
+ </profile>
<!-- The SQLServer2005 (MS JDBC) test envionment -->
<profile>
<id>mssql2005</id>
15 years
Hibernate SVN: r20711 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-09-26 11:42:11 -0400 (Sun, 26 Sep 2010)
New Revision: 20711
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java
Log:
HHH-5598 sybase's getCurrentTimestampSQLFunctionName should be getdate()
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java 2010-09-26 15:39:58 UTC (rev 20710)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java 2010-09-26 15:42:11 UTC (rev 20711)
@@ -69,7 +69,9 @@
public boolean areStringComparisonsCaseInsensitive() {
return true;
}
-
+ public String getCurrentTimestampSQLFunctionName() {
+ return "getdate()";
+ }
/**
* Actually Sybase does not support LOB locators at al.
*
15 years