Hibernate SVN: r18127 - entitymanager/branches/v3_3_2_GA_CP.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-12-04 03:00:47 -0500 (Fri, 04 Dec 2009)
New Revision: 18127
Modified:
entitymanager/branches/v3_3_2_GA_CP/
Log:
ingore .project and .classpath
Property changes on: entitymanager/branches/v3_3_2_GA_CP
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
15 years
Hibernate SVN: r18126 - core/branches/Branch_3_3_2_GA_CP/parent.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-12-03 13:52:07 -0500 (Thu, 03 Dec 2009)
New Revision: 18126
Modified:
core/branches/Branch_3_3_2_GA_CP/parent/pom.xml
Log:
update oracle10g url since looks like that db changed
Modified: core/branches/Branch_3_3_2_GA_CP/parent/pom.xml
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2009-12-03 18:49:07 UTC (rev 18125)
+++ core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2009-12-03 18:52:07 UTC (rev 18126)
@@ -547,7 +547,8 @@
<properties>
<db.dialect>org.hibernate.dialect.Oracle10gDialect</db.dialect>
<jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
- <jdbc.url>jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01</jdbc.url>
+ <jdbc.url>jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10
+ </jdbc.url>
<jdbc.user>hibbr330</jdbc.user>
<jdbc.pass>hibbr330</jdbc.pass>
<jdbc.isolation />
15 years
Hibernate SVN: r18125 - in core/branches/Branch_3_3_2_GA_CP: testsuite and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-12-03 13:49:07 -0500 (Thu, 03 Dec 2009)
New Revision: 18125
Modified:
core/branches/Branch_3_3_2_GA_CP/parent/pom.xml
core/branches/Branch_3_3_2_GA_CP/testsuite/pom.xml
Log:
move db profiles to parent/pom.xml from testsuite/pom.xml
Modified: core/branches/Branch_3_3_2_GA_CP/parent/pom.xml
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2009-12-03 14:54:21 UTC (rev 18124)
+++ core/branches/Branch_3_3_2_GA_CP/parent/pom.xml 2009-12-03 18:49:07 UTC (rev 18125)
@@ -363,7 +363,238 @@
<url>dav:https://snapshots.jboss.org/maven2</url>
</snapshotRepository>
</distributionManagement>
+ <profiles>
+ <!-- HSQLDB is the default (eventually move to H2) -->
+ <profile>
+ <id>hsqldb</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.HSQLDialect</db.dialect>
+ <jdbc.driver>org.hsqldb.jdbcDriver</jdbc.driver>
+ <jdbc.url>jdbc:hsqldb:target/test/db/hsqldb/hibernate</jdbc.url>
+ <jdbc.user>sa</jdbc.user>
+ <jdbc.pass />
+ <jdbc.isolation />
+ </properties>
+ </profile>
+ <!-- The H2 test envionment -->
+ <profile>
+ <id>h2</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.h2database</groupId>
+ <artifactId>h2database</artifactId>
+ <version>1.0.20061217</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.H2Dialect</db.dialect>
+ <jdbc.driver>org.h2.Driver</jdbc.driver>
+ <jdbc.url>jdbc:h2:mem:target/test/db/h2/hibernate</jdbc.url>
+ <jdbc.user>sa</jdbc.user>
+ <jdbc.pass />
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!--
+ ###################################################################
+ Profiles naming db instances in the Red Hat QA/QE lab
+
+ First, those with OSS drivers
+ ###################################################################
+ -->
+
+ <!-- The MySQL5 test envionment -->
+ <profile>
+ <id>mysql5</id>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.0.5</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</db.dialect>
+ <jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
+ <jdbc.url>jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/hibbr330</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!-- The PostgreSQL test envionment -->
+ <profile>
+ <id>postgresql823</id>
+ <dependencies>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.2-504</version>
+ <classifier>jdbc3</classifier>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.PostgreSQLDialect</db.dialect>
+ <jdbc.driver>org.postgresql.Driver</jdbc.driver>
+ <jdbc.url>jdbc:postgresql://dev01.qa.atl.jboss.com:5432:hibbr330</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!--
+ ###################################################################
+ Then, those with commercial drivers
+ ###################################################################
+ -->
+
+ <!-- The DB2 8.x test envionment (using 9x drivers)-->
+ <profile>
+ <id>db2v82</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc_license_cu</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.DB2Dialect</db.dialect>
+ <jdbc.driver>com.ibm.db2.jcc.DB2Driver</jdbc.driver>
+ <jdbc.url>jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!-- The DB2 9.x test envionment (using 9x drivers)-->
+ <profile>
+ <id>db2v91</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc_license_cu</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.DB2Dialect</db.dialect>
+ <jdbc.driver>com.ibm.db2.jcc.DB2Driver</jdbc.driver>
+ <jdbc.url>jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!-- The Oracle9i test envionment -->
+ <profile>
+ <id>oracle9i</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc14</artifactId>
+ <!-- use the 10g drivers which are surprisingly largely bug free -->
+ <version>10.0.2.0</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.Oracle9iDialect</db.dialect>
+ <jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
+ <jdbc.url>jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!-- The Oracle10g test envionment -->
+ <profile>
+ <id>oracle10g</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc14</artifactId>
+ <!-- use the 10g drivers which are surprisingly largely bug free -->
+ <version>10.0.2.0</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.Oracle10gDialect</db.dialect>
+ <jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
+ <jdbc.url>jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!-- The Sybase 15 test envionment -->
+ <profile>
+ <id>sybase15</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.sybase</groupId>
+ <artifactId>jconnect</artifactId>
+ <version>6.0.5</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.SybaseASE15Dialect</db.dialect>
+ <jdbc.driver>com.sybase.jdbc3.jdbc.SybDriver</jdbc.driver>
+ <jdbc.url>jdbc:sybase:Tds:dev77.qa.atl2.redhat.com:5000/hibbr330</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation />
+ </properties>
+ </profile>
+
+ <!-- The SQLServer2005 (MS JDBC) test envionment -->
+ <profile>
+ <id>mssql2005</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.microsoft.sqlserver</groupId>
+ <artifactId>msjdbc</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <db.dialect>org.hibernate.dialect.SQLServerDialect</db.dialect>
+ <jdbc.driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc.driver>
+ <jdbc.url>jdbc:sqlserver://dev30.qa.atl.jboss.com:3918</jdbc.url>
+ <jdbc.user>hibbr330</jdbc.user>
+ <jdbc.pass>hibbr330</jdbc.pass>
+ <jdbc.isolation>4096</jdbc.isolation>
+ </properties>
+ </profile>
+
+ </profiles>
<properties>
<slf4jVersion>1.5.8</slf4jVersion>
</properties>
Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/pom.xml
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/pom.xml 2009-12-03 14:54:21 UTC (rev 18124)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/pom.xml 2009-12-03 18:49:07 UTC (rev 18125)
@@ -95,236 +95,5 @@
</plugins>
</build>
- <profiles>
- <!-- HSQLDB is the default (eventually move to H2) -->
- <profile>
- <id>hsqldb</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencies>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.2</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.HSQLDialect</db.dialect>
- <jdbc.driver>org.hsqldb.jdbcDriver</jdbc.driver>
- <jdbc.url>jdbc:hsqldb:target/test/db/hsqldb/hibernate</jdbc.url>
- <jdbc.user>sa</jdbc.user>
- <jdbc.pass />
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!-- The H2 test envionment -->
- <profile>
- <id>h2</id>
- <dependencies>
- <dependency>
- <groupId>org.h2database</groupId>
- <artifactId>h2database</artifactId>
- <version>1.0.20061217</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.H2Dialect</db.dialect>
- <jdbc.driver>org.h2.Driver</jdbc.driver>
- <jdbc.url>jdbc:h2:mem:target/test/db/h2/hibernate</jdbc.url>
- <jdbc.user>sa</jdbc.user>
- <jdbc.pass />
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!--
- ###################################################################
- Profiles naming db instances in the Red Hat QA/QE lab
-
- First, those with OSS drivers
- ###################################################################
- -->
-
- <!-- The MySQL5 test envionment -->
- <profile>
- <id>mysql5</id>
- <dependencies>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.0.5</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</db.dialect>
- <jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
- <jdbc.url>jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/hibbr330</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!-- The PostgreSQL test envionment -->
- <profile>
- <id>postgresql823</id>
- <dependencies>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>8.2-504</version>
- <classifier>jdbc3</classifier>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.PostgreSQLDialect</db.dialect>
- <jdbc.driver>org.postgresql.Driver</jdbc.driver>
- <jdbc.url>jdbc:postgresql://dev01.qa.atl.jboss.com:5432:hibbr330</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!--
- ###################################################################
- Then, those with commercial drivers
- ###################################################################
- -->
-
- <!-- The DB2 8.x test envionment (using 9x drivers)-->
- <profile>
- <id>db2v82</id>
- <dependencies>
- <dependency>
- <groupId>com.ibm</groupId>
- <artifactId>db2jcc</artifactId>
- <version>3.1.57</version>
- </dependency>
- <dependency>
- <groupId>com.ibm</groupId>
- <artifactId>db2jcc_license_cu</artifactId>
- <version>3.1.57</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.DB2Dialect</db.dialect>
- <jdbc.driver>com.ibm.db2.jcc.DB2Driver</jdbc.driver>
- <jdbc.url>jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!-- The DB2 9.x test envionment (using 9x drivers)-->
- <profile>
- <id>db2v91</id>
- <dependencies>
- <dependency>
- <groupId>com.ibm</groupId>
- <artifactId>db2jcc</artifactId>
- <version>3.1.57</version>
- </dependency>
- <dependency>
- <groupId>com.ibm</groupId>
- <artifactId>db2jcc_license_cu</artifactId>
- <version>3.1.57</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.DB2Dialect</db.dialect>
- <jdbc.driver>com.ibm.db2.jcc.DB2Driver</jdbc.driver>
- <jdbc.url>jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!-- The Oracle9i test envionment -->
- <profile>
- <id>oracle9i</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc14</artifactId>
- <!-- use the 10g drivers which are surprisingly largely bug free -->
- <version>10.0.2.0</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.Oracle9iDialect</db.dialect>
- <jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
- <jdbc.url>jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!-- The Oracle10g test envionment -->
- <profile>
- <id>oracle10g</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc14</artifactId>
- <!-- use the 10g drivers which are surprisingly largely bug free -->
- <version>10.0.2.0</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.Oracle10gDialect</db.dialect>
- <jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
- <jdbc.url>jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!-- The Sybase 15 test envionment -->
- <profile>
- <id>sybase15</id>
- <dependencies>
- <dependency>
- <groupId>com.sybase</groupId>
- <artifactId>jconnect</artifactId>
- <version>6.0.5</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.SybaseASE15Dialect</db.dialect>
- <jdbc.driver>com.sybase.jdbc3.jdbc.SybDriver</jdbc.driver>
- <jdbc.url>jdbc:sybase:Tds:dev77.qa.atl2.redhat.com:5000/hibbr330</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation />
- </properties>
- </profile>
-
- <!-- The SQLServer2005 (MS JDBC) test envionment -->
- <profile>
- <id>mssql2005</id>
- <dependencies>
- <dependency>
- <groupId>com.microsoft.sqlserver</groupId>
- <artifactId>msjdbc</artifactId>
- <version>1.1</version>
- </dependency>
- </dependencies>
- <properties>
- <db.dialect>org.hibernate.dialect.SQLServerDialect</db.dialect>
- <jdbc.driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc.driver>
- <jdbc.url>jdbc:sqlserver://dev30.qa.atl.jboss.com:3918</jdbc.url>
- <jdbc.user>hibbr330</jdbc.user>
- <jdbc.pass>hibbr330</jdbc.pass>
- <jdbc.isolation>4096</jdbc.isolation>
- </properties>
- </profile>
-
- </profiles>
+
</project>
15 years
Hibernate SVN: r18124 - in core/branches/envers-hibernate-3.3/src: main/java/org/hibernate/envers/configuration/metadata and 8 other directories.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-03 09:54:21 -0500 (Thu, 03 Dec 2009)
New Revision: 18124
Added:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java
Removed:
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java
core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java
Modified:
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
core/branches/envers-hibernate-3.3/src/test/resources/hibernate.test.cfg.xml
core/branches/envers-hibernate-3.3/src/test/resources/testng.xml
Log:
svn merge -r 18109:18123 https://svn.jboss.org/repos/hibernate/core/trunk/envers .
Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -41,6 +41,7 @@
import org.hibernate.envers.configuration.metadata.EntityXmlMappingData;
import org.hibernate.envers.configuration.metadata.reader.ClassAuditingData;
import org.hibernate.envers.configuration.metadata.AuditMetadataGenerator;
+import org.hibernate.envers.configuration.metadata.AuditEntityNameRegister;
import org.hibernate.envers.entities.EntitiesConfigurations;
import org.hibernate.envers.tools.StringTools;
import org.hibernate.envers.tools.graph.GraphTopologicalSort;
@@ -57,8 +58,11 @@
public EntitiesConfigurations configure(Configuration cfg, ReflectionManager reflectionManager,
GlobalConfiguration globalCfg, AuditEntitiesConfiguration verEntCfg,
Document revisionInfoXmlMapping, Element revisionInfoRelationMapping) {
+ // Creating a name register to capture all audit entity names created.
+ AuditEntityNameRegister auditEntityNameRegister = new AuditEntityNameRegister();
+
AuditMetadataGenerator auditMetaGen = new AuditMetadataGenerator(cfg, globalCfg, verEntCfg,
- revisionInfoRelationMapping);
+ revisionInfoRelationMapping, auditEntityNameRegister);
DOMWriter writer = new DOMWriter();
// Sorting the persistent class topologically - superclass always before subclass
@@ -76,6 +80,7 @@
new AnnotationsMetadataReader(globalCfg, reflectionManager, pc);
ClassAuditingData auditData = annotationsMetadataReader.getAuditData();
+ EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
if (auditData.isAudited()) {
pcDatas.put(pc, auditData);
@@ -83,14 +88,12 @@
verEntCfg.addCustomAuditTableName(pc.getEntityName(), auditData.getAuditTable().value());
}
- EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
auditMetaGen.generateFirstPass(pc, auditData, xmlMappingData, true);
- xmlMappings.put(pc, xmlMappingData);
} else {
- EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
auditMetaGen.generateFirstPass(pc, auditData, xmlMappingData, false);
- xmlMappings.put(pc, xmlMappingData);
}
+
+ xmlMappings.put(pc, xmlMappingData);
}
// Second pass
Copied: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java (from rev 18123, core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,50 @@
+package org.hibernate.envers.configuration.metadata;
+
+import org.hibernate.MappingException;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * A register of all audit entity names used so far.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditEntityNameRegister {
+ private final Set<String> auditEntityNames = new HashSet<String>();
+
+ /**
+ * @param auditEntityName Name of the audit entity.
+ * @return True if the given audit entity name is already used.
+ */
+ private boolean check(String auditEntityName) {
+ return auditEntityNames.contains(auditEntityName);
+ }
+
+ /**
+ * Register an audit entity name. If the name is already registered, an exception is thrown.
+ * @param auditEntityName Name of the audit entity.
+ */
+ public void register(String auditEntityName) {
+ if (auditEntityNames.contains(auditEntityName)) {
+ throw new MappingException("The audit entity name '" + auditEntityName + "' is already registered.");
+ }
+
+ auditEntityNames.add(auditEntityName);
+ }
+
+ /**
+ * Creates a unique (not yet registered) audit entity name by appending consecutive numbers to the base
+ * name. If the base name is not yet used, it is returned unmodified.
+ * @param baseAuditEntityName The base entity name.
+ * @return
+ */
+ public String createUnique(final String baseAuditEntityName) {
+ String auditEntityName = baseAuditEntityName;
+ int count = 1;
+ while (check(auditEntityName)) {
+ auditEntityName = baseAuditEntityName + count++;
+ }
+
+ return auditEntityName;
+ }
+}
Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -69,12 +69,15 @@
private final Map<String, EntityConfiguration> entitiesConfigurations;
private final Map<String, EntityConfiguration> notAuditedEntitiesConfigurations;
+ private final AuditEntityNameRegister auditEntityNameRegister;
+
// Map entity name -> (join descriptor -> element describing the "versioned" join)
private final Map<String, Map<Join, Element>> entitiesJoins;
public AuditMetadataGenerator(Configuration cfg, GlobalConfiguration globalCfg,
AuditEntitiesConfiguration verEntCfg,
- Element revisionInfoRelationMapping) {
+ Element revisionInfoRelationMapping,
+ AuditEntityNameRegister auditEntityNameRegister) {
this.cfg = cfg;
this.globalCfg = globalCfg;
this.verEntCfg = verEntCfg;
@@ -85,6 +88,8 @@
this.idMetadataGenerator = new IdMetadataGenerator(this);
this.toOneRelationMetadataGenerator = new ToOneRelationMetadataGenerator(this);
+ this.auditEntityNameRegister = auditEntityNameRegister;
+
entitiesConfigurations = new HashMap<String, EntityConfiguration>();
notAuditedEntitiesConfigurations = new HashMap<String, EntityConfiguration>();
entitiesJoins = new HashMap<String, Map<Join, Element>>();
@@ -376,6 +381,9 @@
String auditEntityName = verEntCfg.getAuditEntityName(entityName);
String auditTableName = verEntCfg.getAuditTableName(entityName, pc.getTable().getName());
+ // Registering the audit entity name, now that it is known
+ auditEntityNameRegister.register(auditEntityName);
+
AuditTableData auditTableData = new AuditTableData(auditEntityName, auditTableName, schema, catalog);
// Generating a mapping for the id
@@ -483,6 +491,10 @@
return verEntCfg;
}
+ AuditEntityNameRegister getAuditEntityNameRegister() {
+ return auditEntityNameRegister;
+ }
+
void throwUnsupportedTypeException(Type type, String entityName, String propertyName) {
String message = "Type not supported for auditing: " + type.getClass().getName() +
", on entity " + entityName + ", property '" + propertyName + "'.";
Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -254,8 +254,14 @@
// Generating the XML mapping for the middle entity, only if the relation isn't inverse.
// If the relation is inverse, will be later checked by comparing middleEntityXml with null.
Element middleEntityXml;
- if (!propertyValue.isInverse()) {
- middleEntityXml = createMiddleEntityXml(auditMiddleTableName, auditMiddleEntityName);
+ if (!propertyValue.isInverse()) {
+ // Generating a unique middle entity name
+ auditMiddleEntityName = mainGenerator.getAuditEntityNameRegister().createUnique(auditMiddleEntityName);
+
+ // Registering the generated name
+ mainGenerator.getAuditEntityNameRegister().register(auditMiddleEntityName);
+
+ middleEntityXml = createMiddleEntityXml(auditMiddleTableName, auditMiddleEntityName, propertyValue.getWhere());
} else {
middleEntityXml = null;
}
@@ -474,7 +480,7 @@
}
}
- private Element createMiddleEntityXml(String auditMiddleTableName, String auditMiddleEntityName) {
+ private Element createMiddleEntityXml(String auditMiddleTableName, String auditMiddleEntityName, String where) {
String schema = mainGenerator.getSchema(propertyAuditingData.getJoinTable().schema(), propertyValue.getCollectionTable());
String catalog = mainGenerator.getCatalog(propertyAuditingData.getJoinTable().catalog(), propertyValue.getCollectionTable());
@@ -482,6 +488,11 @@
new AuditTableData(auditMiddleEntityName, auditMiddleTableName, schema, catalog), null);
Element middleEntityXmlId = middleEntityXml.addElement("composite-id");
+ // If there is a where clause on the relation, adding it to the middle entity.
+ if (where != null) {
+ middleEntityXml.addAttribute("where", where);
+ }
+
middleEntityXmlId.addAttribute("name", mainGenerator.getVerEntCfg().getOriginalIdPropName());
// Adding the revision number as a foreign key to the revision info entity to the composite id of the
Modified: core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
===================================================================
--- core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -68,6 +68,15 @@
return prop_mapping;
}
+ private static void addOrModifyAttribute(Element parent, String name, String value) {
+ Attribute attribute = parent.attribute(name);
+ if (attribute == null) {
+ parent.addAttribute(name, value);
+ } else {
+ attribute.setValue(value);
+ }
+ }
+
public static Element addOrModifyColumn(Element parent, String name) {
Element column_mapping = parent.element("column");
@@ -76,12 +85,7 @@
}
if (!StringTools.isEmpty(name)) {
- Attribute nameAttribute = column_mapping.attribute("name");
- if (nameAttribute == null) {
- column_mapping.addAttribute("name", name);
- } else {
- nameAttribute.setValue(name);
- }
+ addOrModifyAttribute(column_mapping, "name", name);
}
return column_mapping;
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,93 @@
+/*
+ * 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.test.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+public class IntNoAutoIdTestEntity {
+ @Id
+ private Integer id;
+
+ @Audited
+ private Integer number;
+
+ public IntNoAutoIdTestEntity() {
+ }
+
+ public IntNoAutoIdTestEntity(Integer number, Integer id) {
+ this.id = id;
+ this.number = number;
+ }
+
+ public IntNoAutoIdTestEntity(Integer number) {
+ this.number = number;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Integer getNumber() {
+ return number;
+ }
+
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof IntNoAutoIdTestEntity)) return false;
+
+ IntNoAutoIdTestEntity that = (IntNoAutoIdTestEntity) o;
+
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ //noinspection RedundantIfStatement
+ if (number != null ? !number.equals(that.number) : that.number != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (number != null ? number.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "INATE(id = " + id + ", number = " + number + ")";
+ }
+}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,96 @@
+package org.hibernate.envers.test.entities.manytomany;
+
+import org.hibernate.envers.Audited;
+import org.hibernate.envers.test.entities.IntNoAutoIdTestEntity;
+import org.hibernate.annotations.WhereJoinTable;
+
+import javax.persistence.*;
+import java.util.List;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class WhereJoinTableEntity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String data;
+
+ @ManyToMany
+ @JoinTable(
+ name = "wjte_ite_join",
+ joinColumns = @JoinColumn(name = "wjte_id"),
+ inverseJoinColumns = @JoinColumn(name = "ite_id")
+ )
+ @WhereJoinTable(clause = "ite_id < 20")
+ private List<IntNoAutoIdTestEntity> references1;
+
+ @ManyToMany
+ @JoinTable(
+ name = "wjte_ite_join",
+ joinColumns = @JoinColumn(name = "wjte_id"),
+ inverseJoinColumns = @JoinColumn(name = "ite_id")
+ )
+ @WhereJoinTable(clause = "ite_id >= 20")
+ private List<IntNoAutoIdTestEntity> references2;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public List<IntNoAutoIdTestEntity> getReferences1() {
+ return references1;
+ }
+
+ public void setReferences1(List<IntNoAutoIdTestEntity> references1) {
+ this.references1 = references1;
+ }
+
+ public List<IntNoAutoIdTestEntity> getReferences2() {
+ return references2;
+ }
+
+ public void setReferences2(List<IntNoAutoIdTestEntity> references2) {
+ this.references2 = references2;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ WhereJoinTableEntity that = (WhereJoinTableEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "WJTE(id = " + id + ", data = " + data + ")";
+ }
+}
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned)
Deleted: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -1,111 +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.test.entities.manytomany.biowned;
-
-import java.util.List;
-import java.util.ArrayList;
-import javax.persistence.*;
-
-import org.hibernate.envers.Audited;
-
-/**
- * Entity owning a many-to-many relation, where the other entity also owns the relation.
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-public class ListBiowning1Entity {
- @Id
- @GeneratedValue
- private Integer id;
-
- private String data;
-
- @ManyToMany
- @JoinTable(
- name = "biowning",
- joinColumns = @JoinColumn(name = "biowning1_id"),
- inverseJoinColumns = @JoinColumn(name = "biowning2_id", insertable = false, updatable = false)
- )
- private List<ListBiowning2Entity> references = new ArrayList<ListBiowning2Entity>();
-
- public ListBiowning1Entity() { }
-
- public ListBiowning1Entity(Integer id, String data) {
- this.id = id;
- this.data = data;
- }
-
- public ListBiowning1Entity(String data) {
- this.data = data;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public List<ListBiowning2Entity> getReferences() {
- return references;
- }
-
- public void setReferences(List<ListBiowning2Entity> references) {
- this.references = references;
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ListBiowning1Entity)) return false;
-
- ListBiowning1Entity that = (ListBiowning1Entity) o;
-
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
- //noinspection RedundantIfStatement
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = (id != null ? id.hashCode() : 0);
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "ListBiowning1Entity(id = " + id + ", data = " + data + ")";
- }
-}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,111 @@
+/*
+ * 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.test.entities.manytomany.biowned;
+
+import java.util.List;
+import java.util.ArrayList;
+import javax.persistence.*;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * Entity owning a many-to-many relation, where the other entity also owns the relation.
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class ListBiowning1Entity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String data;
+
+ @ManyToMany
+ @JoinTable(
+ name = "biowning",
+ joinColumns = @JoinColumn(name = "biowning1_id"),
+ inverseJoinColumns = @JoinColumn(name = "biowning2_id", insertable = false, updatable = false)
+ )
+ private List<ListBiowning2Entity> references = new ArrayList<ListBiowning2Entity>();
+
+ public ListBiowning1Entity() { }
+
+ public ListBiowning1Entity(Integer id, String data) {
+ this.id = id;
+ this.data = data;
+ }
+
+ public ListBiowning1Entity(String data) {
+ this.data = data;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public List<ListBiowning2Entity> getReferences() {
+ return references;
+ }
+
+ public void setReferences(List<ListBiowning2Entity> references) {
+ this.references = references;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ListBiowning1Entity)) return false;
+
+ ListBiowning1Entity that = (ListBiowning1Entity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "ListBiowning1Entity(id = " + id + ", data = " + data + ")";
+ }
+}
\ No newline at end of file
Deleted: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -1,111 +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.test.entities.manytomany.biowned;
-
-import java.util.List;
-import java.util.ArrayList;
-import javax.persistence.*;
-
-import org.hibernate.envers.Audited;
-
-/**
- * Entity owning a many-to-many relation, where the other entity also owns the relation.
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-public class ListBiowning2Entity {
- @Id
- @GeneratedValue
- private Integer id;
-
- private String data;
-
- @ManyToMany
- @JoinTable(
- name = "biowning",
- joinColumns = @JoinColumn(name = "biowning2_id"),
- inverseJoinColumns = @JoinColumn(name = "biowning1_id", insertable = false, updatable = false)
- )
- private List<ListBiowning1Entity> references = new ArrayList<ListBiowning1Entity>();
-
- public ListBiowning2Entity() { }
-
- public ListBiowning2Entity(Integer id, String data) {
- this.id = id;
- this.data = data;
- }
-
- public ListBiowning2Entity(String data) {
- this.data = data;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public List<ListBiowning1Entity> getReferences() {
- return references;
- }
-
- public void setReferences(List<ListBiowning1Entity> references) {
- this.references = references;
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ListBiowning2Entity)) return false;
-
- ListBiowning2Entity that = (ListBiowning2Entity) o;
-
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
- //noinspection RedundantIfStatement
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = (id != null ? id.hashCode() : 0);
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "ListBiowning2Entity(id = " + id + ", data = " + data + ")";
- }
-}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,111 @@
+/*
+ * 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.test.entities.manytomany.biowned;
+
+import java.util.List;
+import java.util.ArrayList;
+import javax.persistence.*;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * Entity owning a many-to-many relation, where the other entity also owns the relation.
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class ListBiowning2Entity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String data;
+
+ @ManyToMany
+ @JoinTable(
+ name = "biowning",
+ joinColumns = @JoinColumn(name = "biowning2_id"),
+ inverseJoinColumns = @JoinColumn(name = "biowning1_id", insertable = false, updatable = false)
+ )
+ private List<ListBiowning1Entity> references = new ArrayList<ListBiowning1Entity>();
+
+ public ListBiowning2Entity() { }
+
+ public ListBiowning2Entity(Integer id, String data) {
+ this.id = id;
+ this.data = data;
+ }
+
+ public ListBiowning2Entity(String data) {
+ this.data = data;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public List<ListBiowning1Entity> getReferences() {
+ return references;
+ }
+
+ public void setReferences(List<ListBiowning1Entity> references) {
+ this.references = references;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ListBiowning2Entity)) return false;
+
+ ListBiowning2Entity that = (ListBiowning2Entity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "ListBiowning2Entity(id = " + id + ", data = " + data + ")";
+ }
+}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable)
Deleted: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -1,91 +0,0 @@
-package org.hibernate.envers.test.entities.manytomany.sametable;
-
-import org.hibernate.annotations.WhereJoinTable;
-import org.hibernate.envers.Audited;
-
-import javax.persistence.*;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-public class Child1Entity {
- @Id
- @GeneratedValue
- private Integer id;
-
- private String child1Data;
-
- public Child1Entity() {
- }
-
- public Child1Entity(String child1Data) {
- this.child1Data = child1Data;
- }
-
- public Child1Entity(String child1Data, Integer id) {
- this.child1Data = child1Data;
- this.id = id;
- }
-
- @ManyToMany(fetch = FetchType.LAZY)
- @JoinTable(
- name = "children",
- joinColumns = @JoinColumn(name = "child1_id"),
- inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false)
- )
- @WhereJoinTable(clause = "child1_id is not null")
- private List<ParentEntity> parents = new ArrayList<ParentEntity>();
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getChild1Data() {
- return child1Data;
- }
-
- public void setChild1Data(String child1Data) {
- this.child1Data = child1Data;
- }
-
- public List<ParentEntity> getParents() {
- return parents;
- }
-
- public void setParents(List<ParentEntity> parents) {
- this.parents = parents;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Child1Entity that = (Child1Entity) o;
-
- if (child1Data != null ? !child1Data.equals(that.child1Data) : that.child1Data != null) return false;
- //noinspection RedundantIfStatement
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (child1Data != null ? child1Data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "C1E(id = " + id + ", child1Data = " + child1Data + ")";
- }
-}
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,91 @@
+package org.hibernate.envers.test.entities.manytomany.sametable;
+
+import org.hibernate.annotations.WhereJoinTable;
+import org.hibernate.envers.Audited;
+
+import javax.persistence.*;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class Child1Entity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String child1Data;
+
+ public Child1Entity() {
+ }
+
+ public Child1Entity(String child1Data) {
+ this.child1Data = child1Data;
+ }
+
+ public Child1Entity(String child1Data, Integer id) {
+ this.child1Data = child1Data;
+ this.id = id;
+ }
+
+ @ManyToMany(fetch = FetchType.LAZY)
+ @JoinTable(
+ name = "children",
+ joinColumns = @JoinColumn(name = "child1_id"),
+ inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false)
+ )
+ @WhereJoinTable(clause = "child1_id is not null")
+ private List<ParentEntity> parents = new ArrayList<ParentEntity>();
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getChild1Data() {
+ return child1Data;
+ }
+
+ public void setChild1Data(String child1Data) {
+ this.child1Data = child1Data;
+ }
+
+ public List<ParentEntity> getParents() {
+ return parents;
+ }
+
+ public void setParents(List<ParentEntity> parents) {
+ this.parents = parents;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Child1Entity that = (Child1Entity) o;
+
+ if (child1Data != null ? !child1Data.equals(that.child1Data) : that.child1Data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (child1Data != null ? child1Data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "C1E(id = " + id + ", child1Data = " + child1Data + ")";
+ }
+}
Deleted: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -1,91 +0,0 @@
-package org.hibernate.envers.test.entities.manytomany.sametable;
-
-import org.hibernate.annotations.WhereJoinTable;
-import org.hibernate.envers.Audited;
-
-import javax.persistence.*;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-public class Child2Entity {
- @Id
- @GeneratedValue
- private Integer id;
-
- private String child2Data;
-
- public Child2Entity() {
- }
-
- public Child2Entity(String child2Data) {
- this.child2Data = child2Data;
- }
-
- public Child2Entity(Integer id, String child2Data) {
- this.id = id;
- this.child2Data = child2Data;
- }
-
- @ManyToMany(fetch = FetchType.LAZY)
- @JoinTable(
- name = "children",
- joinColumns = @JoinColumn(name = "child2_id"),
- inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false)
- )
- @WhereJoinTable(clause = "child2_id is not null")
- private List<ParentEntity> parents = new ArrayList<ParentEntity>();
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getChild2Data() {
- return child2Data;
- }
-
- public void setChild2Data(String child2Data) {
- this.child2Data = child2Data;
- }
-
- public List<ParentEntity> getParents() {
- return parents;
- }
-
- public void setParents(List<ParentEntity> parents) {
- this.parents = parents;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Child2Entity that = (Child2Entity) o;
-
- if (child2Data != null ? !child2Data.equals(that.child2Data) : that.child2Data != null) return false;
- //noinspection RedundantIfStatement
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (child2Data != null ? child2Data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "C2E(id = " + id + ", child2Data = " + child2Data + ")";
- }
-}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,91 @@
+package org.hibernate.envers.test.entities.manytomany.sametable;
+
+import org.hibernate.annotations.WhereJoinTable;
+import org.hibernate.envers.Audited;
+
+import javax.persistence.*;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class Child2Entity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String child2Data;
+
+ public Child2Entity() {
+ }
+
+ public Child2Entity(String child2Data) {
+ this.child2Data = child2Data;
+ }
+
+ public Child2Entity(Integer id, String child2Data) {
+ this.id = id;
+ this.child2Data = child2Data;
+ }
+
+ @ManyToMany(fetch = FetchType.LAZY)
+ @JoinTable(
+ name = "children",
+ joinColumns = @JoinColumn(name = "child2_id"),
+ inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false)
+ )
+ @WhereJoinTable(clause = "child2_id is not null")
+ private List<ParentEntity> parents = new ArrayList<ParentEntity>();
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getChild2Data() {
+ return child2Data;
+ }
+
+ public void setChild2Data(String child2Data) {
+ this.child2Data = child2Data;
+ }
+
+ public List<ParentEntity> getParents() {
+ return parents;
+ }
+
+ public void setParents(List<ParentEntity> parents) {
+ this.parents = parents;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Child2Entity that = (Child2Entity) o;
+
+ if (child2Data != null ? !child2Data.equals(that.child2Data) : that.child2Data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (child2Data != null ? child2Data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "C2E(id = " + id + ", child2Data = " + child2Data + ")";
+ }
+}
\ No newline at end of file
Deleted: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -1,108 +0,0 @@
-package org.hibernate.envers.test.entities.manytomany.sametable;
-
-import org.hibernate.envers.Audited;
-import org.hibernate.annotations.WhereJoinTable;
-
-import javax.persistence.*;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-@Audited
-public class ParentEntity {
- @Id
- @GeneratedValue
- private Integer id;
-
- private String parentData;
-
- public ParentEntity() {
- }
-
- public ParentEntity(String parentData) {
- this.parentData = parentData;
- }
-
- public ParentEntity(Integer id, String parentData) {
- this.id = id;
- this.parentData = parentData;
- }
-
- @ManyToMany(fetch = FetchType.LAZY)
- @JoinTable(
- name = "children",
- joinColumns = @JoinColumn(name = "parent_id"),
- inverseJoinColumns = @JoinColumn(name = "child1_id", insertable = false, updatable = false)
- )
- @WhereJoinTable(clause = "child1_id is not null")
- private List<Child1Entity> children1 = new ArrayList<Child1Entity>();
-
- @ManyToMany(fetch = FetchType.LAZY)
- @JoinTable(
- name = "children",
- joinColumns = @JoinColumn(name = "parent_id"),
- inverseJoinColumns = @JoinColumn(name = "child2_id", insertable = false, updatable = false)
- )
- @WhereJoinTable(clause = "child2_id is not null")
- private List<Child2Entity> children2 = new ArrayList<Child2Entity>();
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getParentData() {
- return parentData;
- }
-
- public void setParentData(String parentData) {
- this.parentData = parentData;
- }
-
- public List<Child1Entity> getChildren1() {
- return children1;
- }
-
- public void setChildren1(List<Child1Entity> children1) {
- this.children1 = children1;
- }
-
- public List<Child2Entity> getChildren2() {
- return children2;
- }
-
- public void setChildren2(List<Child2Entity> children2) {
- this.children2 = children2;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- ParentEntity that = (ParentEntity) o;
-
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
- //noinspection RedundantIfStatement
- if (parentData != null ? !parentData.equals(that.parentData) : that.parentData != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (parentData != null ? parentData.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "PE(id = " + id + ", parentData = " + parentData + ")";
- }
-}
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,108 @@
+package org.hibernate.envers.test.entities.manytomany.sametable;
+
+import org.hibernate.envers.Audited;
+import org.hibernate.annotations.WhereJoinTable;
+
+import javax.persistence.*;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class ParentEntity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String parentData;
+
+ public ParentEntity() {
+ }
+
+ public ParentEntity(String parentData) {
+ this.parentData = parentData;
+ }
+
+ public ParentEntity(Integer id, String parentData) {
+ this.id = id;
+ this.parentData = parentData;
+ }
+
+ @ManyToMany(fetch = FetchType.LAZY)
+ @JoinTable(
+ name = "children",
+ joinColumns = @JoinColumn(name = "parent_id"),
+ inverseJoinColumns = @JoinColumn(name = "child1_id", insertable = false, updatable = false)
+ )
+ @WhereJoinTable(clause = "child1_id is not null")
+ private List<Child1Entity> children1 = new ArrayList<Child1Entity>();
+
+ @ManyToMany(fetch = FetchType.LAZY)
+ @JoinTable(
+ name = "children",
+ joinColumns = @JoinColumn(name = "parent_id"),
+ inverseJoinColumns = @JoinColumn(name = "child2_id", insertable = false, updatable = false)
+ )
+ @WhereJoinTable(clause = "child2_id is not null")
+ private List<Child2Entity> children2 = new ArrayList<Child2Entity>();
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getParentData() {
+ return parentData;
+ }
+
+ public void setParentData(String parentData) {
+ this.parentData = parentData;
+ }
+
+ public List<Child1Entity> getChildren1() {
+ return children1;
+ }
+
+ public void setChildren1(List<Child1Entity> children1) {
+ this.children1 = children1;
+ }
+
+ public List<Child2Entity> getChildren2() {
+ return children2;
+ }
+
+ public void setChildren2(List<Child2Entity> children2) {
+ this.children2 = children2;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ParentEntity that = (ParentEntity) o;
+
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ //noinspection RedundantIfStatement
+ if (parentData != null ? !parentData.equals(that.parentData) : that.parentData != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (parentData != null ? parentData.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "PE(id = " + id + ", parentData = " + parentData + ")";
+ }
+}
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,186 @@
+/*
+ * 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.test.integration.manytomany;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.entities.IntNoAutoIdTestEntity;
+import org.hibernate.envers.test.entities.manytomany.WhereJoinTableEntity;
+import org.hibernate.envers.test.tools.TestTools;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicWhereJoinTable extends AbstractEntityTest {
+ private Integer ite1_1_id;
+ private Integer ite1_2_id;
+ private Integer ite2_1_id;
+ private Integer ite2_2_id;
+
+ private Integer wjte1_id;
+ private Integer wjte2_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(WhereJoinTableEntity.class);
+ cfg.addAnnotatedClass(IntNoAutoIdTestEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ IntNoAutoIdTestEntity ite1_1 = new IntNoAutoIdTestEntity(1, 10);
+ IntNoAutoIdTestEntity ite1_2 = new IntNoAutoIdTestEntity(1, 11);
+ IntNoAutoIdTestEntity ite2_1 = new IntNoAutoIdTestEntity(2, 20);
+ IntNoAutoIdTestEntity ite2_2 = new IntNoAutoIdTestEntity(2, 21);
+
+ WhereJoinTableEntity wjte1 = new WhereJoinTableEntity();
+ wjte1.setData("wjte1");
+
+ WhereJoinTableEntity wjte2 = new WhereJoinTableEntity();
+ wjte1.setData("wjte2");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(ite1_1);
+ em.persist(ite1_2);
+ em.persist(ite2_1);
+ em.persist(ite2_2);
+ em.persist(wjte1);
+ em.persist(wjte2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 2 (wjte1: 1_1, 2_1)
+
+ em.getTransaction().begin();
+
+ wjte1 = em.find(WhereJoinTableEntity.class, wjte1.getId());
+
+ wjte1.getReferences1().add(ite1_1);
+ wjte1.getReferences2().add(ite2_1);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 3 (wjte1: 1_1, 2_1; wjte2: 1_1, 1_2)
+ em.getTransaction().begin();
+
+ wjte2 = em.find(WhereJoinTableEntity.class, wjte2.getId());
+
+ wjte2.getReferences1().add(ite1_1);
+ wjte2.getReferences1().add(ite1_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 4 (wjte1: 2_1; wjte2: 1_1, 1_2, 2_2)
+ em.getTransaction().begin();
+
+ wjte1 = em.find(WhereJoinTableEntity.class, wjte1.getId());
+ wjte2 = em.find(WhereJoinTableEntity.class, wjte2.getId());
+
+ wjte1.getReferences1().remove(ite1_1);
+ wjte2.getReferences2().add(ite2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ //
+
+ ite1_1_id = ite1_1.getId();
+ ite1_2_id = ite1_2.getId();
+ ite2_1_id = ite2_1.getId();
+ ite2_2_id = ite2_2.getId();
+
+ wjte1_id = wjte1.getId();
+ wjte2_id = wjte2.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assertEquals(Arrays.asList(1, 2, 4), getAuditReader().getRevisions(WhereJoinTableEntity.class, wjte1_id));
+ assertEquals(Arrays.asList(1, 3, 4), getAuditReader().getRevisions(WhereJoinTableEntity.class, wjte2_id));
+
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite1_1_id));
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite1_2_id));
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite2_1_id));
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite2_2_id));
+ }
+
+ @Test
+ public void testHistoryOfWjte1() {
+ IntNoAutoIdTestEntity ite1_1 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite1_1_id);
+ IntNoAutoIdTestEntity ite2_1 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite2_1_id);
+
+ WhereJoinTableEntity rev1 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 1);
+ WhereJoinTableEntity rev2 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 2);
+ WhereJoinTableEntity rev3 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 3);
+ WhereJoinTableEntity rev4 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 4);
+
+ // Checking 1st list
+ assert TestTools.checkList(rev1.getReferences1());
+ assert TestTools.checkList(rev2.getReferences1(), ite1_1);
+ assert TestTools.checkList(rev3.getReferences1(), ite1_1);
+ assert TestTools.checkList(rev4.getReferences1());
+
+ // Checking 2nd list
+ assert TestTools.checkList(rev1.getReferences2());
+ assert TestTools.checkList(rev2.getReferences2(), ite2_1);
+ assert TestTools.checkList(rev3.getReferences2(), ite2_1);
+ assert TestTools.checkList(rev4.getReferences2(), ite2_1);
+ }
+
+ @Test
+ public void testHistoryOfWjte2() {
+ IntNoAutoIdTestEntity ite1_1 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite1_1_id);
+ IntNoAutoIdTestEntity ite1_2 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite1_2_id);
+ IntNoAutoIdTestEntity ite2_2 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite2_2_id);
+
+ WhereJoinTableEntity rev1 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 1);
+ WhereJoinTableEntity rev2 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 2);
+ WhereJoinTableEntity rev3 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 3);
+ WhereJoinTableEntity rev4 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 4);
+
+ // Checking 1st list
+ assert TestTools.checkList(rev1.getReferences1());
+ assert TestTools.checkList(rev2.getReferences1());
+ assert TestTools.checkList(rev3.getReferences1(), ite1_1, ite1_2);
+ assert TestTools.checkList(rev4.getReferences1(), ite1_1, ite1_2);
+
+ // Checking 2nd list
+ assert TestTools.checkList(rev1.getReferences2());
+ assert TestTools.checkList(rev2.getReferences2());
+ assert TestTools.checkList(rev3.getReferences2());
+ assert TestTools.checkList(rev4.getReferences2(), ite2_2);
+ }
+}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned)
Deleted: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -1,220 +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.test.integration.manytomany.biowned;
-
-import org.hibernate.ejb.Ejb3Configuration;
-import org.hibernate.envers.test.AbstractEntityTest;
-import org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning1Entity;
-import org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning2Entity;
-import org.hibernate.envers.test.tools.TestTools;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
-import static org.testng.Assert.assertEquals;
-
-import javax.persistence.EntityManager;
-import java.util.Arrays;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class BasicBiowned extends AbstractEntityTest {
- private Integer o1_1_id;
- private Integer o1_2_id;
- private Integer o2_1_id;
- private Integer o2_2_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(ListBiowning1Entity.class);
- cfg.addAnnotatedClass(ListBiowning2Entity.class);
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- ListBiowning1Entity o1_1 = new ListBiowning1Entity("o1_1");
- ListBiowning1Entity o1_2 = new ListBiowning1Entity("o1_2");
- ListBiowning2Entity o2_1 = new ListBiowning2Entity("o2_1");
- ListBiowning2Entity o2_2 = new ListBiowning2Entity("o2_2");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(o1_1);
- em.persist(o1_2);
- em.persist(o2_1);
- em.persist(o2_2);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 2 (1_1 <-> 2_1; 1_2 <-> 2_2)
-
- em.getTransaction().begin();
-
- o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
- o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
- o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
- o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
-
- o1_1.getReferences().add(o2_1);
- o1_2.getReferences().add(o2_2);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 3 (1_1 <-> 2_1, 2_2; 1_2 <-> 2_2)
- em.getTransaction().begin();
-
- o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
- o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
-
- o1_1.getReferences().add(o2_2);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 4 (1_2 <-> 2_1, 2_2)
- em.getTransaction().begin();
-
- o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
- o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
- o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
- o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
-
- o2_2.getReferences().remove(o1_1);
- o2_1.getReferences().remove(o1_1);
- o2_1.getReferences().add(o1_2);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 5 (1_1 <-> 2_2, 1_2 <-> 2_2)
- em.getTransaction().begin();
-
- o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
- o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
- o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
- o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
-
- o1_2.getReferences().remove(o2_1);
- o1_1.getReferences().add(o2_2);
-
- em.getTransaction().commit();
- em.clear();
-
- //
-
- o1_1_id = o1_1.getId();
- o1_2_id = o1_2.getId();
- o2_1_id = o2_1.getId();
- o2_2_id = o2_2.getId();
- }
-
- @Test(enabled = true)
- public void testRevisionsCounts() {
- // Although it would seem that when modifying references both entities should be marked as modified, because
- // ownly the owning side is notified (because of the bi-owning mapping), a revision is created only for
- // the entity where the collection was directly modified.
-
- assertEquals(Arrays.asList(1, 2, 3, 5), getAuditReader().getRevisions(ListBiowning1Entity.class, o1_1_id));
- assertEquals(Arrays.asList(1, 2, 5), getAuditReader().getRevisions(ListBiowning1Entity.class, o1_2_id));
-
- assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_1_id));
- assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_2_id));
- }
-
- @Test(enabled = true)
- public void testHistoryOfO1_1() {
- ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
- ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
-
- ListBiowning1Entity rev1 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 1);
- ListBiowning1Entity rev2 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 2);
- ListBiowning1Entity rev3 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 3);
- ListBiowning1Entity rev4 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 4);
- ListBiowning1Entity rev5 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 5);
-
- assert TestTools.checkList(rev1.getReferences());
- assert TestTools.checkList(rev2.getReferences(), o2_1);
- assert TestTools.checkList(rev3.getReferences(), o2_1, o2_2);
- assert TestTools.checkList(rev4.getReferences());
- assert TestTools.checkList(rev5.getReferences(), o2_2);
- }
-
- @Test(enabled = true)
- public void testHistoryOfO1_2() {
- ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
- ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
-
- ListBiowning1Entity rev1 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 1);
- ListBiowning1Entity rev2 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 2);
- ListBiowning1Entity rev3 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 3);
- ListBiowning1Entity rev4 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 4);
- ListBiowning1Entity rev5 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 5);
-
- assert TestTools.checkList(rev1.getReferences());
- assert TestTools.checkList(rev2.getReferences(), o2_2);
- assert TestTools.checkList(rev3.getReferences(), o2_2);
- assert TestTools.checkList(rev4.getReferences(), o2_1, o2_2);
- System.out.println("rev5.getReferences() = " + rev5.getReferences());
- assert TestTools.checkList(rev5.getReferences(), o2_2);
- }
-
- @Test(enabled = true)
- public void testHistoryOfO2_1() {
- ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
- ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
-
- ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 1);
- ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 2);
- ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 3);
- ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 4);
- ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 5);
-
- assert TestTools.checkList(rev1.getReferences());
- assert TestTools.checkList(rev2.getReferences(), o1_1);
- assert TestTools.checkList(rev3.getReferences(), o1_1);
- assert TestTools.checkList(rev4.getReferences(), o1_2);
- assert TestTools.checkList(rev5.getReferences());
- }
-
- @Test(enabled = true)
- public void testHistoryOfO2_2() {
- ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
- ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
-
- ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 1);
- ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 2);
- ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 3);
- ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 4);
- ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 5);
-
- assert TestTools.checkList(rev1.getReferences());
- assert TestTools.checkList(rev2.getReferences(), o1_2);
- assert TestTools.checkList(rev3.getReferences(), o1_1, o1_2);
- assert TestTools.checkList(rev4.getReferences(), o1_2);
- assert TestTools.checkList(rev5.getReferences(), o1_1, o1_2);
- }
-}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,220 @@
+/*
+ * 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.test.integration.manytomany.biowned;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning1Entity;
+import org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning2Entity;
+import org.hibernate.envers.test.tools.TestTools;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
+import static org.testng.Assert.assertEquals;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicBiowned extends AbstractEntityTest {
+ private Integer o1_1_id;
+ private Integer o1_2_id;
+ private Integer o2_1_id;
+ private Integer o2_2_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(ListBiowning1Entity.class);
+ cfg.addAnnotatedClass(ListBiowning2Entity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ ListBiowning1Entity o1_1 = new ListBiowning1Entity("o1_1");
+ ListBiowning1Entity o1_2 = new ListBiowning1Entity("o1_2");
+ ListBiowning2Entity o2_1 = new ListBiowning2Entity("o2_1");
+ ListBiowning2Entity o2_2 = new ListBiowning2Entity("o2_2");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(o1_1);
+ em.persist(o1_2);
+ em.persist(o2_1);
+ em.persist(o2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 2 (1_1 <-> 2_1; 1_2 <-> 2_2)
+
+ em.getTransaction().begin();
+
+ o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
+ o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
+ o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
+ o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
+
+ o1_1.getReferences().add(o2_1);
+ o1_2.getReferences().add(o2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 3 (1_1 <-> 2_1, 2_2; 1_2 <-> 2_2)
+ em.getTransaction().begin();
+
+ o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
+ o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
+
+ o1_1.getReferences().add(o2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 4 (1_2 <-> 2_1, 2_2)
+ em.getTransaction().begin();
+
+ o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
+ o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
+ o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
+ o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
+
+ o2_2.getReferences().remove(o1_1);
+ o2_1.getReferences().remove(o1_1);
+ o2_1.getReferences().add(o1_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 5 (1_1 <-> 2_2, 1_2 <-> 2_2)
+ em.getTransaction().begin();
+
+ o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
+ o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
+ o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
+ o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
+
+ o1_2.getReferences().remove(o2_1);
+ o1_1.getReferences().add(o2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ //
+
+ o1_1_id = o1_1.getId();
+ o1_2_id = o1_2.getId();
+ o2_1_id = o2_1.getId();
+ o2_2_id = o2_2.getId();
+ }
+
+ @Test(enabled = true)
+ public void testRevisionsCounts() {
+ // Although it would seem that when modifying references both entities should be marked as modified, because
+ // ownly the owning side is notified (because of the bi-owning mapping), a revision is created only for
+ // the entity where the collection was directly modified.
+
+ assertEquals(Arrays.asList(1, 2, 3, 5), getAuditReader().getRevisions(ListBiowning1Entity.class, o1_1_id));
+ assertEquals(Arrays.asList(1, 2, 5), getAuditReader().getRevisions(ListBiowning1Entity.class, o1_2_id));
+
+ assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_1_id));
+ assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_2_id));
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfO1_1() {
+ ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
+ ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
+
+ ListBiowning1Entity rev1 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 1);
+ ListBiowning1Entity rev2 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 2);
+ ListBiowning1Entity rev3 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 3);
+ ListBiowning1Entity rev4 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 4);
+ ListBiowning1Entity rev5 = getAuditReader().find(ListBiowning1Entity.class, o1_1_id, 5);
+
+ assert TestTools.checkList(rev1.getReferences());
+ assert TestTools.checkList(rev2.getReferences(), o2_1);
+ assert TestTools.checkList(rev3.getReferences(), o2_1, o2_2);
+ assert TestTools.checkList(rev4.getReferences());
+ assert TestTools.checkList(rev5.getReferences(), o2_2);
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfO1_2() {
+ ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
+ ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
+
+ ListBiowning1Entity rev1 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 1);
+ ListBiowning1Entity rev2 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 2);
+ ListBiowning1Entity rev3 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 3);
+ ListBiowning1Entity rev4 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 4);
+ ListBiowning1Entity rev5 = getAuditReader().find(ListBiowning1Entity.class, o1_2_id, 5);
+
+ assert TestTools.checkList(rev1.getReferences());
+ assert TestTools.checkList(rev2.getReferences(), o2_2);
+ assert TestTools.checkList(rev3.getReferences(), o2_2);
+ assert TestTools.checkList(rev4.getReferences(), o2_1, o2_2);
+ System.out.println("rev5.getReferences() = " + rev5.getReferences());
+ assert TestTools.checkList(rev5.getReferences(), o2_2);
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfO2_1() {
+ ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
+ ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
+
+ ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 1);
+ ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 2);
+ ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 3);
+ ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 4);
+ ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 5);
+
+ assert TestTools.checkList(rev1.getReferences());
+ assert TestTools.checkList(rev2.getReferences(), o1_1);
+ assert TestTools.checkList(rev3.getReferences(), o1_1);
+ assert TestTools.checkList(rev4.getReferences(), o1_2);
+ assert TestTools.checkList(rev5.getReferences());
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfO2_2() {
+ ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
+ ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
+
+ ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 1);
+ ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 2);
+ ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 3);
+ ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 4);
+ ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 5);
+
+ assert TestTools.checkList(rev1.getReferences());
+ assert TestTools.checkList(rev2.getReferences(), o1_2);
+ assert TestTools.checkList(rev3.getReferences(), o1_1, o1_2);
+ assert TestTools.checkList(rev4.getReferences(), o1_2);
+ assert TestTools.checkList(rev5.getReferences(), o1_1, o1_2);
+ }
+}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable)
Deleted: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -1,297 +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.test.integration.manytomany.sametable;
-
-import java.util.Arrays;
-import javax.persistence.EntityManager;
-
-import org.hibernate.envers.test.AbstractEntityTest;
-import org.hibernate.envers.test.entities.manytomany.sametable.ParentEntity;
-import org.hibernate.envers.test.entities.manytomany.sametable.Child1Entity;
-import org.hibernate.envers.test.entities.manytomany.sametable.Child2Entity;
-import org.hibernate.envers.test.tools.TestTools;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.ejb.Ejb3Configuration;
-import org.hibernate.Session;
-
-/**
- * Test which checks that auditing entities which contain multiple mappings to same tables work.
- * @author Adam Warski (adam at warski dot org)
- */
-public class BasicSametable extends AbstractEntityTest {
- private Integer p1_id;
- private Integer p2_id;
- private Integer c1_1_id;
- private Integer c1_2_id;
- private Integer c2_1_id;
- private Integer c2_2_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(ParentEntity.class);
- cfg.addAnnotatedClass(Child1Entity.class);
- cfg.addAnnotatedClass(Child2Entity.class);
- }
-
- @BeforeClass(enabled = true, dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- // We need first to modify the columns in the middle (join table) to allow null values. Hbm2ddl doesn't seem
- // to allow this.
- em.getTransaction().begin();
- Session session = (Session) em.getDelegate();
- session.createSQLQuery("DROP TABLE children").executeUpdate();
- session.createSQLQuery("CREATE TABLE children(parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
- session.createSQLQuery("DROP TABLE children_AUD").executeUpdate();
- session.createSQLQuery("CREATE TABLE children_AUD(REV integer NOT NULL, REVTYPE tinyint, " +
- "parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
- em.getTransaction().commit();
- em.clear();
-
- ParentEntity p1 = new ParentEntity("parent_1");
- ParentEntity p2 = new ParentEntity("parent_2");
-
- Child1Entity c1_1 = new Child1Entity("child1_1");
- Child1Entity c1_2 = new Child1Entity("child1_2");
-
- Child2Entity c2_1 = new Child2Entity("child2_1");
- Child2Entity c2_2 = new Child2Entity("child2_2");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(p1);
- em.persist(p2);
- em.persist(c1_1);
- em.persist(c1_2);
- em.persist(c2_1);
- em.persist(c2_2);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 2 - (p1: c1_1, p2: c2_1)
-
- em.getTransaction().begin();
-
- p1 = em.find(ParentEntity.class, p1.getId());
- p2 = em.find(ParentEntity.class, p2.getId());
- c1_1 = em.find(Child1Entity.class, c1_1.getId());
- c2_1 = em.find(Child2Entity.class, c2_1.getId());
-
- p1.getChildren1().add(c1_1);
- p2.getChildren2().add(c2_1);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 3 - (p1: c1_1, c1_2, c2_2, p2: c1_1, c2_1)
- em.getTransaction().begin();
-
- p1 = em.find(ParentEntity.class, p1.getId());
- p2 = em.find(ParentEntity.class, p2.getId());
- c1_1 = em.find(Child1Entity.class, c1_1.getId());
- c1_2 = em.find(Child1Entity.class, c1_2.getId());
- c2_2 = em.find(Child2Entity.class, c2_2.getId());
-
- p1.getChildren1().add(c1_2);
- p1.getChildren2().add(c2_2);
-
- p2.getChildren1().add(c1_1);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 4 - (p1: c1_2, c2_2, p2: c1_1, c2_1, c2_2)
- em.getTransaction().begin();
-
- p1 = em.find(ParentEntity.class, p1.getId());
- p2 = em.find(ParentEntity.class, p2.getId());
- c1_1 = em.find(Child1Entity.class, c1_1.getId());
- c2_2 = em.find(Child2Entity.class, c2_2.getId());
-
- p1.getChildren1().remove(c1_1);
- p2.getChildren2().add(c2_2);
-
- em.getTransaction().commit();
- em.clear();
-
- // Revision 5 - (p1: c2_2, p2: c1_1, c2_1)
- em.getTransaction().begin();
-
- p1 = em.find(ParentEntity.class, p1.getId());
- p2 = em.find(ParentEntity.class, p2.getId());
- c1_2 = em.find(Child1Entity.class, c1_2.getId());
- c2_2 = em.find(Child2Entity.class, c2_2.getId());
-
- c2_2.getParents().remove(p2);
- c1_2.getParents().remove(p1);
-
- em.getTransaction().commit();
- em.clear();
-
- //
-
- p1_id = p1.getId();
- p2_id = p2.getId();
- c1_1_id = c1_1.getId();
- c1_2_id = c1_2.getId();
- c2_1_id = c2_1.getId();
- c2_2_id = c2_2.getId();
- }
-
- @Test(enabled = true)
- public void testRevisionsCounts() {
- assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p1_id));
- assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p2_id));
-
- assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c1_1_id));
- assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c1_2_id));
-
- assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c2_1_id));
- assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c2_2_id));
- }
-
- @Test(enabled = true)
- public void testHistoryOfParent1() {
- Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
- Child1Entity c1_2 = getEntityManager().find(Child1Entity.class, c1_2_id);
- Child2Entity c2_2 = getEntityManager().find(Child2Entity.class, c2_2_id);
-
- ParentEntity rev1 = getAuditReader().find(ParentEntity.class, p1_id, 1);
- ParentEntity rev2 = getAuditReader().find(ParentEntity.class, p1_id, 2);
- ParentEntity rev3 = getAuditReader().find(ParentEntity.class, p1_id, 3);
- ParentEntity rev4 = getAuditReader().find(ParentEntity.class, p1_id, 4);
- ParentEntity rev5 = getAuditReader().find(ParentEntity.class, p1_id, 5);
-
- assert TestTools.checkList(rev1.getChildren1());
- assert TestTools.checkList(rev2.getChildren1(), c1_1);
- assert TestTools.checkList(rev3.getChildren1(), c1_1, c1_2);
- assert TestTools.checkList(rev4.getChildren1(), c1_2);
- assert TestTools.checkList(rev5.getChildren1());
-
- assert TestTools.checkList(rev1.getChildren2());
- assert TestTools.checkList(rev2.getChildren2());
- assert TestTools.checkList(rev3.getChildren2(), c2_2);
- assert TestTools.checkList(rev4.getChildren2(), c2_2);
- assert TestTools.checkList(rev5.getChildren2(), c2_2);
- }
-
- @Test(enabled = true)
- public void testHistoryOfParent2() {
- Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
- Child2Entity c2_1 = getEntityManager().find(Child2Entity.class, c2_1_id);
- Child2Entity c2_2 = getEntityManager().find(Child2Entity.class, c2_2_id);
-
- ParentEntity rev1 = getAuditReader().find(ParentEntity.class, p2_id, 1);
- ParentEntity rev2 = getAuditReader().find(ParentEntity.class, p2_id, 2);
- ParentEntity rev3 = getAuditReader().find(ParentEntity.class, p2_id, 3);
- ParentEntity rev4 = getAuditReader().find(ParentEntity.class, p2_id, 4);
- ParentEntity rev5 = getAuditReader().find(ParentEntity.class, p2_id, 5);
-
- assert TestTools.checkList(rev1.getChildren1());
- assert TestTools.checkList(rev2.getChildren1());
- assert TestTools.checkList(rev3.getChildren1(), c1_1);
- assert TestTools.checkList(rev4.getChildren1(), c1_1);
- assert TestTools.checkList(rev5.getChildren1(), c1_1);
-
- assert TestTools.checkList(rev1.getChildren2());
- assert TestTools.checkList(rev2.getChildren2(), c2_1);
- assert TestTools.checkList(rev3.getChildren2(), c2_1);
- assert TestTools.checkList(rev4.getChildren2(), c2_1, c2_2);
- assert TestTools.checkList(rev5.getChildren2(), c2_1);
- }
-
- @Test(enabled = true)
- public void testHistoryOfChild1_1() {
- ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
- ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
-
- Child1Entity rev1 = getAuditReader().find(Child1Entity.class, c1_1_id, 1);
- Child1Entity rev2 = getAuditReader().find(Child1Entity.class, c1_1_id, 2);
- Child1Entity rev3 = getAuditReader().find(Child1Entity.class, c1_1_id, 3);
- Child1Entity rev4 = getAuditReader().find(Child1Entity.class, c1_1_id, 4);
- Child1Entity rev5 = getAuditReader().find(Child1Entity.class, c1_1_id, 5);
-
- assert TestTools.checkList(rev1.getParents());
- assert TestTools.checkList(rev2.getParents(), p1);
- assert TestTools.checkList(rev3.getParents(), p1, p2);
- assert TestTools.checkList(rev4.getParents(), p2);
- assert TestTools.checkList(rev5.getParents(), p2);
- }
-
- @Test(enabled = false)
- public void testHistoryOfChild1_2() {
- ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
-
- Child1Entity rev1 = getAuditReader().find(Child1Entity.class, c1_2_id, 1);
- Child1Entity rev2 = getAuditReader().find(Child1Entity.class, c1_2_id, 2);
- Child1Entity rev3 = getAuditReader().find(Child1Entity.class, c1_2_id, 3);
- Child1Entity rev4 = getAuditReader().find(Child1Entity.class, c1_2_id, 4);
- Child1Entity rev5 = getAuditReader().find(Child1Entity.class, c1_2_id, 5);
-
- assert TestTools.checkList(rev1.getParents());
- assert TestTools.checkList(rev2.getParents());
- assert TestTools.checkList(rev3.getParents(), p1);
- assert TestTools.checkList(rev4.getParents(), p1);
- assert TestTools.checkList(rev5.getParents());
- }
-
- @Test(enabled = true)
- public void testHistoryOfChild2_1() {
- ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
-
- Child2Entity rev1 = getAuditReader().find(Child2Entity.class, c2_1_id, 1);
- Child2Entity rev2 = getAuditReader().find(Child2Entity.class, c2_1_id, 2);
- Child2Entity rev3 = getAuditReader().find(Child2Entity.class, c2_1_id, 3);
- Child2Entity rev4 = getAuditReader().find(Child2Entity.class, c2_1_id, 4);
- Child2Entity rev5 = getAuditReader().find(Child2Entity.class, c2_1_id, 5);
-
- assert TestTools.checkList(rev1.getParents());
- assert TestTools.checkList(rev2.getParents(), p2);
- assert TestTools.checkList(rev3.getParents(), p2);
- assert TestTools.checkList(rev4.getParents(), p2);
- assert TestTools.checkList(rev5.getParents(), p2);
- }
-
- @Test(enabled = true)
- public void testHistoryOfChild2_2() {
- ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
- ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
-
- Child2Entity rev1 = getAuditReader().find(Child2Entity.class, c2_2_id, 1);
- Child2Entity rev2 = getAuditReader().find(Child2Entity.class, c2_2_id, 2);
- Child2Entity rev3 = getAuditReader().find(Child2Entity.class, c2_2_id, 3);
- Child2Entity rev4 = getAuditReader().find(Child2Entity.class, c2_2_id, 4);
- Child2Entity rev5 = getAuditReader().find(Child2Entity.class, c2_2_id, 5);
-
- assert TestTools.checkList(rev1.getParents());
- assert TestTools.checkList(rev2.getParents());
- assert TestTools.checkList(rev3.getParents(), p1);
- assert TestTools.checkList(rev4.getParents(), p1, p2);
- assert TestTools.checkList(rev5.getParents(), p1);
- }
-}
\ No newline at end of file
Copied: core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java (from rev 18123, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java)
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java (rev 0)
+++ core/branches/envers-hibernate-3.3/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java 2009-12-03 14:54:21 UTC (rev 18124)
@@ -0,0 +1,297 @@
+/*
+ * 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.test.integration.manytomany.sametable;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.entities.manytomany.sametable.ParentEntity;
+import org.hibernate.envers.test.entities.manytomany.sametable.Child1Entity;
+import org.hibernate.envers.test.entities.manytomany.sametable.Child2Entity;
+import org.hibernate.envers.test.tools.TestTools;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.Session;
+
+/**
+ * Test which checks that auditing entities which contain multiple mappings to same tables work.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicSametable extends AbstractEntityTest {
+ private Integer p1_id;
+ private Integer p2_id;
+ private Integer c1_1_id;
+ private Integer c1_2_id;
+ private Integer c2_1_id;
+ private Integer c2_2_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(ParentEntity.class);
+ cfg.addAnnotatedClass(Child1Entity.class);
+ cfg.addAnnotatedClass(Child2Entity.class);
+ }
+
+ @BeforeClass(enabled = true, dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ // We need first to modify the columns in the middle (join table) to allow null values. Hbm2ddl doesn't seem
+ // to allow this.
+ em.getTransaction().begin();
+ Session session = (Session) em.getDelegate();
+ session.createSQLQuery("DROP TABLE children").executeUpdate();
+ session.createSQLQuery("CREATE TABLE children(parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
+ session.createSQLQuery("DROP TABLE children_AUD").executeUpdate();
+ session.createSQLQuery("CREATE TABLE children_AUD(REV integer NOT NULL, REVTYPE tinyint, " +
+ "parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
+ em.getTransaction().commit();
+ em.clear();
+
+ ParentEntity p1 = new ParentEntity("parent_1");
+ ParentEntity p2 = new ParentEntity("parent_2");
+
+ Child1Entity c1_1 = new Child1Entity("child1_1");
+ Child1Entity c1_2 = new Child1Entity("child1_2");
+
+ Child2Entity c2_1 = new Child2Entity("child2_1");
+ Child2Entity c2_2 = new Child2Entity("child2_2");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(p1);
+ em.persist(p2);
+ em.persist(c1_1);
+ em.persist(c1_2);
+ em.persist(c2_1);
+ em.persist(c2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 2 - (p1: c1_1, p2: c2_1)
+
+ em.getTransaction().begin();
+
+ p1 = em.find(ParentEntity.class, p1.getId());
+ p2 = em.find(ParentEntity.class, p2.getId());
+ c1_1 = em.find(Child1Entity.class, c1_1.getId());
+ c2_1 = em.find(Child2Entity.class, c2_1.getId());
+
+ p1.getChildren1().add(c1_1);
+ p2.getChildren2().add(c2_1);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 3 - (p1: c1_1, c1_2, c2_2, p2: c1_1, c2_1)
+ em.getTransaction().begin();
+
+ p1 = em.find(ParentEntity.class, p1.getId());
+ p2 = em.find(ParentEntity.class, p2.getId());
+ c1_1 = em.find(Child1Entity.class, c1_1.getId());
+ c1_2 = em.find(Child1Entity.class, c1_2.getId());
+ c2_2 = em.find(Child2Entity.class, c2_2.getId());
+
+ p1.getChildren1().add(c1_2);
+ p1.getChildren2().add(c2_2);
+
+ p2.getChildren1().add(c1_1);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 4 - (p1: c1_2, c2_2, p2: c1_1, c2_1, c2_2)
+ em.getTransaction().begin();
+
+ p1 = em.find(ParentEntity.class, p1.getId());
+ p2 = em.find(ParentEntity.class, p2.getId());
+ c1_1 = em.find(Child1Entity.class, c1_1.getId());
+ c2_2 = em.find(Child2Entity.class, c2_2.getId());
+
+ p1.getChildren1().remove(c1_1);
+ p2.getChildren2().add(c2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 5 - (p1: c2_2, p2: c1_1, c2_1)
+ em.getTransaction().begin();
+
+ p1 = em.find(ParentEntity.class, p1.getId());
+ p2 = em.find(ParentEntity.class, p2.getId());
+ c1_2 = em.find(Child1Entity.class, c1_2.getId());
+ c2_2 = em.find(Child2Entity.class, c2_2.getId());
+
+ c2_2.getParents().remove(p2);
+ c1_2.getParents().remove(p1);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ //
+
+ p1_id = p1.getId();
+ p2_id = p2.getId();
+ c1_1_id = c1_1.getId();
+ c1_2_id = c1_2.getId();
+ c2_1_id = c2_1.getId();
+ c2_2_id = c2_2.getId();
+ }
+
+ @Test(enabled = true)
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p1_id));
+ assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p2_id));
+
+ assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c1_1_id));
+ assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c1_2_id));
+
+ assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c2_1_id));
+ assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c2_2_id));
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfParent1() {
+ Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
+ Child1Entity c1_2 = getEntityManager().find(Child1Entity.class, c1_2_id);
+ Child2Entity c2_2 = getEntityManager().find(Child2Entity.class, c2_2_id);
+
+ ParentEntity rev1 = getAuditReader().find(ParentEntity.class, p1_id, 1);
+ ParentEntity rev2 = getAuditReader().find(ParentEntity.class, p1_id, 2);
+ ParentEntity rev3 = getAuditReader().find(ParentEntity.class, p1_id, 3);
+ ParentEntity rev4 = getAuditReader().find(ParentEntity.class, p1_id, 4);
+ ParentEntity rev5 = getAuditReader().find(ParentEntity.class, p1_id, 5);
+
+ assert TestTools.checkList(rev1.getChildren1());
+ assert TestTools.checkList(rev2.getChildren1(), c1_1);
+ assert TestTools.checkList(rev3.getChildren1(), c1_1, c1_2);
+ assert TestTools.checkList(rev4.getChildren1(), c1_2);
+ assert TestTools.checkList(rev5.getChildren1());
+
+ assert TestTools.checkList(rev1.getChildren2());
+ assert TestTools.checkList(rev2.getChildren2());
+ assert TestTools.checkList(rev3.getChildren2(), c2_2);
+ assert TestTools.checkList(rev4.getChildren2(), c2_2);
+ assert TestTools.checkList(rev5.getChildren2(), c2_2);
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfParent2() {
+ Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
+ Child2Entity c2_1 = getEntityManager().find(Child2Entity.class, c2_1_id);
+ Child2Entity c2_2 = getEntityManager().find(Child2Entity.class, c2_2_id);
+
+ ParentEntity rev1 = getAuditReader().find(ParentEntity.class, p2_id, 1);
+ ParentEntity rev2 = getAuditReader().find(ParentEntity.class, p2_id, 2);
+ ParentEntity rev3 = getAuditReader().find(ParentEntity.class, p2_id, 3);
+ ParentEntity rev4 = getAuditReader().find(ParentEntity.class, p2_id, 4);
+ ParentEntity rev5 = getAuditReader().find(ParentEntity.class, p2_id, 5);
+
+ assert TestTools.checkList(rev1.getChildren1());
+ assert TestTools.checkList(rev2.getChildren1());
+ assert TestTools.checkList(rev3.getChildren1(), c1_1);
+ assert TestTools.checkList(rev4.getChildren1(), c1_1);
+ assert TestTools.checkList(rev5.getChildren1(), c1_1);
+
+ assert TestTools.checkList(rev1.getChildren2());
+ assert TestTools.checkList(rev2.getChildren2(), c2_1);
+ assert TestTools.checkList(rev3.getChildren2(), c2_1);
+ assert TestTools.checkList(rev4.getChildren2(), c2_1, c2_2);
+ assert TestTools.checkList(rev5.getChildren2(), c2_1);
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfChild1_1() {
+ ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
+ ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
+
+ Child1Entity rev1 = getAuditReader().find(Child1Entity.class, c1_1_id, 1);
+ Child1Entity rev2 = getAuditReader().find(Child1Entity.class, c1_1_id, 2);
+ Child1Entity rev3 = getAuditReader().find(Child1Entity.class, c1_1_id, 3);
+ Child1Entity rev4 = getAuditReader().find(Child1Entity.class, c1_1_id, 4);
+ Child1Entity rev5 = getAuditReader().find(Child1Entity.class, c1_1_id, 5);
+
+ assert TestTools.checkList(rev1.getParents());
+ assert TestTools.checkList(rev2.getParents(), p1);
+ assert TestTools.checkList(rev3.getParents(), p1, p2);
+ assert TestTools.checkList(rev4.getParents(), p2);
+ assert TestTools.checkList(rev5.getParents(), p2);
+ }
+
+ @Test(enabled = false)
+ public void testHistoryOfChild1_2() {
+ ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
+
+ Child1Entity rev1 = getAuditReader().find(Child1Entity.class, c1_2_id, 1);
+ Child1Entity rev2 = getAuditReader().find(Child1Entity.class, c1_2_id, 2);
+ Child1Entity rev3 = getAuditReader().find(Child1Entity.class, c1_2_id, 3);
+ Child1Entity rev4 = getAuditReader().find(Child1Entity.class, c1_2_id, 4);
+ Child1Entity rev5 = getAuditReader().find(Child1Entity.class, c1_2_id, 5);
+
+ assert TestTools.checkList(rev1.getParents());
+ assert TestTools.checkList(rev2.getParents());
+ assert TestTools.checkList(rev3.getParents(), p1);
+ assert TestTools.checkList(rev4.getParents(), p1);
+ assert TestTools.checkList(rev5.getParents());
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfChild2_1() {
+ ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
+
+ Child2Entity rev1 = getAuditReader().find(Child2Entity.class, c2_1_id, 1);
+ Child2Entity rev2 = getAuditReader().find(Child2Entity.class, c2_1_id, 2);
+ Child2Entity rev3 = getAuditReader().find(Child2Entity.class, c2_1_id, 3);
+ Child2Entity rev4 = getAuditReader().find(Child2Entity.class, c2_1_id, 4);
+ Child2Entity rev5 = getAuditReader().find(Child2Entity.class, c2_1_id, 5);
+
+ assert TestTools.checkList(rev1.getParents());
+ assert TestTools.checkList(rev2.getParents(), p2);
+ assert TestTools.checkList(rev3.getParents(), p2);
+ assert TestTools.checkList(rev4.getParents(), p2);
+ assert TestTools.checkList(rev5.getParents(), p2);
+ }
+
+ @Test(enabled = true)
+ public void testHistoryOfChild2_2() {
+ ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
+ ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
+
+ Child2Entity rev1 = getAuditReader().find(Child2Entity.class, c2_2_id, 1);
+ Child2Entity rev2 = getAuditReader().find(Child2Entity.class, c2_2_id, 2);
+ Child2Entity rev3 = getAuditReader().find(Child2Entity.class, c2_2_id, 3);
+ Child2Entity rev4 = getAuditReader().find(Child2Entity.class, c2_2_id, 4);
+ Child2Entity rev5 = getAuditReader().find(Child2Entity.class, c2_2_id, 5);
+
+ assert TestTools.checkList(rev1.getParents());
+ assert TestTools.checkList(rev2.getParents());
+ assert TestTools.checkList(rev3.getParents(), p1);
+ assert TestTools.checkList(rev4.getParents(), p1, p2);
+ assert TestTools.checkList(rev5.getParents(), p1);
+ }
+}
\ No newline at end of file
Modified: core/branches/envers-hibernate-3.3/src/test/resources/hibernate.test.cfg.xml
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/resources/hibernate.test.cfg.xml 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/resources/hibernate.test.cfg.xml 2009-12-03 14:54:21 UTC (rev 18124)
@@ -17,13 +17,13 @@
<property name="connection.username">sa</property>
<property name="connection.password"></property>
- <!--<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
- <property name="connection.url">jdbc:mysql:///hibernate_tests?useUnicode=true&characterEncoding=UTF-8</property>
- <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
- <property name="connection.username">root</property>
- <property name="connection.password"></property>
+ <!--<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>-->
+ <!--<property name="connection.url">jdbc:mysql:///hibernate_tests?useUnicode=true&characterEncoding=UTF-8</property>-->
+ <!--<property name="connection.driver_class">com.mysql.jdbc.Driver</property>-->
+ <!--<property name="connection.username">root</property>-->
+ <!--<property name="connection.password"></property>-->
- <property name="hibernate.jdbc.batch_size">100</property>-->
+ <!--<property name="hibernate.jdbc.batch_size">100</property>-->
<!--<event type="post-insert">
<listener class="org.hibernate.envers.event.AuditEventListener" />
Modified: core/branches/envers-hibernate-3.3/src/test/resources/testng.xml
===================================================================
--- core/branches/envers-hibernate-3.3/src/test/resources/testng.xml 2009-12-03 14:47:45 UTC (rev 18123)
+++ core/branches/envers-hibernate-3.3/src/test/resources/testng.xml 2009-12-03 14:54:21 UTC (rev 18124)
@@ -31,6 +31,8 @@
<package name="org.hibernate.envers.test.integration.interfaces.components" />
<package name="org.hibernate.envers.test.integration.interfaces.relation" />
<package name="org.hibernate.envers.test.integration.manytomany" />
+ <package name="org.hibernate.envers.test.integration.manytomany.biowned" />
+ <package name="org.hibernate.envers.test.integration.manytomany.sametable" />
<package name="org.hibernate.envers.test.integration.manytomany.ternary" />
<package name="org.hibernate.envers.test.integration.manytomany.unidirectional" />
<package name="org.hibernate.envers.test.integration.manytoone.unidirectional" />
15 years
Hibernate SVN: r18123 - core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-03 09:47:45 -0500 (Thu, 03 Dec 2009)
New Revision: 18123
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java
Log:
HHH-4633:
- enabling and fixing the test for same-table m2m mapppings
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java 2009-12-03 14:39:52 UTC (rev 18122)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child1Entity.java 2009-12-03 14:47:45 UTC (rev 18123)
@@ -13,7 +13,8 @@
@Entity
@Audited
public class Child1Entity {
- @Id
+ @Id
+ @GeneratedValue
private Integer id;
private String child1Data;
@@ -63,7 +64,6 @@
this.parents = parents;
}
- @SuppressWarnings({"RedundantIfStatement"})
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -72,6 +72,7 @@
Child1Entity that = (Child1Entity) o;
if (child1Data != null ? !child1Data.equals(that.child1Data) : that.child1Data != null) return false;
+ //noinspection RedundantIfStatement
if (id != null ? !id.equals(that.id) : that.id != null) return false;
return true;
@@ -81,7 +82,10 @@
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (child1Data != null ? child1Data.hashCode() : 0);
- result = 31 * result + (parents != null ? parents.hashCode() : 0);
return result;
}
+
+ public String toString() {
+ return "C1E(id = " + id + ", child1Data = " + child1Data + ")";
+ }
}
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java 2009-12-03 14:39:52 UTC (rev 18122)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/Child2Entity.java 2009-12-03 14:47:45 UTC (rev 18123)
@@ -13,7 +13,8 @@
@Entity
@Audited
public class Child2Entity {
- @Id
+ @Id
+ @GeneratedValue
private Integer id;
private String child2Data;
@@ -81,7 +82,10 @@
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (child2Data != null ? child2Data.hashCode() : 0);
- result = 31 * result + (parents != null ? parents.hashCode() : 0);
return result;
}
+
+ public String toString() {
+ return "C2E(id = " + id + ", child2Data = " + child2Data + ")";
+ }
}
\ No newline at end of file
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java 2009-12-03 14:39:52 UTC (rev 18122)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/sametable/ParentEntity.java 2009-12-03 14:47:45 UTC (rev 18123)
@@ -14,6 +14,7 @@
@Audited
public class ParentEntity {
@Id
+ @GeneratedValue
private Integer id;
private String parentData;
@@ -87,9 +88,9 @@
ParentEntity that = (ParentEntity) o;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ //noinspection RedundantIfStatement
if (parentData != null ? !parentData.equals(that.parentData) : that.parentData != null) return false;
- //noinspection RedundantIfStatement
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
return true;
}
@@ -98,8 +99,10 @@
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (parentData != null ? parentData.hashCode() : 0);
- result = 31 * result + (children1 != null ? children1.hashCode() : 0);
- result = 31 * result + (children2 != null ? children2.hashCode() : 0);
return result;
}
+
+ public String toString() {
+ return "PE(id = " + id + ", parentData = " + parentData + ")";
+ }
}
15 years
Hibernate SVN: r18122 - core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-03 09:39:52 -0500 (Thu, 03 Dec 2009)
New Revision: 18122
Modified:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java
Log:
HHH-4633:
- enabling and fixing the test for same-table m2m mapppings
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java 2009-12-03 14:34:33 UTC (rev 18121)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/sametable/BasicSametable.java 2009-12-03 14:39:52 UTC (rev 18122)
@@ -35,6 +35,7 @@
import org.testng.annotations.Test;
import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.Session;
/**
* Test which checks that auditing entities which contain multiple mappings to same tables work.
@@ -49,15 +50,27 @@
private Integer c2_2_id;
public void configure(Ejb3Configuration cfg) {
- //cfg.addAnnotatedClass(ParentEntity.class);
- //cfg.addAnnotatedClass(Child1Entity.class);
- //cfg.addAnnotatedClass(Child2Entity.class);
+ cfg.addAnnotatedClass(ParentEntity.class);
+ cfg.addAnnotatedClass(Child1Entity.class);
+ cfg.addAnnotatedClass(Child2Entity.class);
}
- //@BeforeClass(enabled = false, dependsOnMethods = "init")
+ @BeforeClass(enabled = true, dependsOnMethods = "init")
public void initData() {
EntityManager em = getEntityManager();
+ // We need first to modify the columns in the middle (join table) to allow null values. Hbm2ddl doesn't seem
+ // to allow this.
+ em.getTransaction().begin();
+ Session session = (Session) em.getDelegate();
+ session.createSQLQuery("DROP TABLE children").executeUpdate();
+ session.createSQLQuery("CREATE TABLE children(parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
+ session.createSQLQuery("DROP TABLE children_AUD").executeUpdate();
+ session.createSQLQuery("CREATE TABLE children_AUD(REV integer NOT NULL, REVTYPE tinyint, " +
+ "parent_id integer, child1_id integer NULL, child2_id integer NULL)").executeUpdate();
+ em.getTransaction().commit();
+ em.clear();
+
ParentEntity p1 = new ParentEntity("parent_1");
ParentEntity p2 = new ParentEntity("parent_2");
@@ -78,6 +91,7 @@
em.persist(c2_2);
em.getTransaction().commit();
+ em.clear();
// Revision 2 - (p1: c1_1, p2: c2_1)
@@ -92,6 +106,7 @@
p2.getChildren2().add(c2_1);
em.getTransaction().commit();
+ em.clear();
// Revision 3 - (p1: c1_1, c1_2, c2_2, p2: c1_1, c2_1)
em.getTransaction().begin();
@@ -108,6 +123,7 @@
p2.getChildren1().add(c1_1);
em.getTransaction().commit();
+ em.clear();
// Revision 4 - (p1: c1_2, c2_2, p2: c1_1, c2_1, c2_2)
em.getTransaction().begin();
@@ -121,6 +137,7 @@
p2.getChildren2().add(c2_2);
em.getTransaction().commit();
+ em.clear();
// Revision 5 - (p1: c2_2, p2: c1_1, c2_1)
em.getTransaction().begin();
@@ -134,6 +151,7 @@
c1_2.getParents().remove(p1);
em.getTransaction().commit();
+ em.clear();
//
@@ -145,21 +163,22 @@
c2_2_id = c2_2.getId();
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testRevisionsCounts() {
- assert Arrays.asList(1, 2, 3, 4, 5).equals(getAuditReader().getRevisions(ParentEntity.class, p1_id));
- assert Arrays.asList(1, 2, 3, 4, 5).equals(getAuditReader().getRevisions(ParentEntity.class, p2_id));
+ assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p1_id));
+ assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(ParentEntity.class, p2_id));
- assert Arrays.asList(1, 2, 3, 4).equals(getAuditReader().getRevisions(Child1Entity.class, c1_1_id));
- assert Arrays.asList(1, 3, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c1_2_id));
+ assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c1_1_id));
+ assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c1_2_id));
- assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(Child1Entity.class, c2_1_id));
- assert Arrays.asList(1, 3, 4, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c2_2_id));
+ assert Arrays.asList(1).equals(getAuditReader().getRevisions(Child1Entity.class, c2_1_id));
+ assert Arrays.asList(1, 5).equals(getAuditReader().getRevisions(Child1Entity.class, c2_2_id));
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfParent1() {
Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
+ Child1Entity c1_2 = getEntityManager().find(Child1Entity.class, c1_2_id);
Child2Entity c2_2 = getEntityManager().find(Child2Entity.class, c2_2_id);
ParentEntity rev1 = getAuditReader().find(ParentEntity.class, p1_id, 1);
@@ -169,10 +188,10 @@
ParentEntity rev5 = getAuditReader().find(ParentEntity.class, p1_id, 5);
assert TestTools.checkList(rev1.getChildren1());
- assert TestTools.checkList(rev2.getChildren1());
- assert TestTools.checkList(rev3.getChildren1(), c1_1);
- assert TestTools.checkList(rev4.getChildren1(), c1_1);
- assert TestTools.checkList(rev5.getChildren1(), c1_1);
+ assert TestTools.checkList(rev2.getChildren1(), c1_1);
+ assert TestTools.checkList(rev3.getChildren1(), c1_1, c1_2);
+ assert TestTools.checkList(rev4.getChildren1(), c1_2);
+ assert TestTools.checkList(rev5.getChildren1());
assert TestTools.checkList(rev1.getChildren2());
assert TestTools.checkList(rev2.getChildren2());
@@ -181,10 +200,9 @@
assert TestTools.checkList(rev5.getChildren2(), c2_2);
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfParent2() {
Child1Entity c1_1 = getEntityManager().find(Child1Entity.class, c1_1_id);
- Child1Entity c1_2 = getEntityManager().find(Child1Entity.class, c1_2_id);
Child2Entity c2_1 = getEntityManager().find(Child2Entity.class, c2_1_id);
Child2Entity c2_2 = getEntityManager().find(Child2Entity.class, c2_2_id);
@@ -195,10 +213,10 @@
ParentEntity rev5 = getAuditReader().find(ParentEntity.class, p2_id, 5);
assert TestTools.checkList(rev1.getChildren1());
- assert TestTools.checkList(rev2.getChildren1(), c1_1);
- assert TestTools.checkList(rev3.getChildren1(), c1_1, c1_2);
- assert TestTools.checkList(rev4.getChildren1(), c1_2);
- assert TestTools.checkList(rev5.getChildren1());
+ assert TestTools.checkList(rev2.getChildren1());
+ assert TestTools.checkList(rev3.getChildren1(), c1_1);
+ assert TestTools.checkList(rev4.getChildren1(), c1_1);
+ assert TestTools.checkList(rev5.getChildren1(), c1_1);
assert TestTools.checkList(rev1.getChildren2());
assert TestTools.checkList(rev2.getChildren2(), c2_1);
@@ -207,7 +225,7 @@
assert TestTools.checkList(rev5.getChildren2(), c2_1);
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfChild1_1() {
ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
@@ -242,7 +260,7 @@
assert TestTools.checkList(rev5.getParents());
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfChild2_1() {
ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
@@ -259,7 +277,7 @@
assert TestTools.checkList(rev5.getParents(), p2);
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfChild2_2() {
ParentEntity p1 = getEntityManager().find(ParentEntity.class, p1_id);
ParentEntity p2 = getEntityManager().find(ParentEntity.class, p2_id);
15 years
Hibernate SVN: r18121 - search/branches/v3_1_1_GA_CP.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-12-03 09:34:33 -0500 (Thu, 03 Dec 2009)
New Revision: 18121
Modified:
search/branches/v3_1_1_GA_CP/pom.xml
Log:
JBPAPP-3210 Hibernate Search branch v3_1_1_GA_CP depends on core 3.3.1 which should be 3.3.2
Modified: search/branches/v3_1_1_GA_CP/pom.xml
===================================================================
--- search/branches/v3_1_1_GA_CP/pom.xml 2009-12-03 10:23:16 UTC (rev 18120)
+++ search/branches/v3_1_1_GA_CP/pom.xml 2009-12-03 14:34:33 UTC (rev 18121)
@@ -243,6 +243,18 @@
</goals>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-test-ext-plugin</artifactId>
+ <version>1.1.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>extend</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<testResources>
<testResource>
@@ -777,7 +789,7 @@
<properties>
<slf4jVersion>1.4.2</slf4jVersion>
<luceneVersion>2.4.1</luceneVersion>
- <hibernateVersion>3.3.1.GA</hibernateVersion>
+ <hibernateVersion>3.3.2.GA</hibernateVersion>
</properties>
</project>
15 years
Hibernate SVN: r18120 - in core/trunk/envers/src: test/java/org/hibernate/envers/test/entities and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-03 05:23:16 -0500 (Thu, 03 Dec 2009)
New Revision: 18120
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
Log:
HHH-4633:
- supporting where clauses on collections (e.g. @WhereJoinTable)
- test
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-12-03 09:03:35 UTC (rev 18119)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-12-03 10:23:16 UTC (rev 18120)
@@ -260,8 +260,8 @@
// Registering the generated name
mainGenerator.getAuditEntityNameRegister().register(auditMiddleEntityName);
-
- middleEntityXml = createMiddleEntityXml(auditMiddleTableName, auditMiddleEntityName);
+
+ middleEntityXml = createMiddleEntityXml(auditMiddleTableName, auditMiddleEntityName, propertyValue.getWhere());
} else {
middleEntityXml = null;
}
@@ -480,7 +480,7 @@
}
}
- private Element createMiddleEntityXml(String auditMiddleTableName, String auditMiddleEntityName) {
+ private Element createMiddleEntityXml(String auditMiddleTableName, String auditMiddleEntityName, String where) {
String schema = mainGenerator.getSchema(propertyAuditingData.getJoinTable().schema(), propertyValue.getCollectionTable());
String catalog = mainGenerator.getCatalog(propertyAuditingData.getJoinTable().catalog(), propertyValue.getCollectionTable());
@@ -488,6 +488,11 @@
new AuditTableData(auditMiddleEntityName, auditMiddleTableName, schema, catalog), null);
Element middleEntityXmlId = middleEntityXml.addElement("composite-id");
+ // If there is a where clause on the relation, adding it to the middle entity.
+ if (where != null) {
+ middleEntityXml.addAttribute("where", where);
+ }
+
middleEntityXmlId.addAttribute("name", mainGenerator.getVerEntCfg().getOriginalIdPropName());
// Adding the revision number as a foreign key to the revision info entity to the composite id of the
Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java (from rev 18113, core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/IntTestEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/IntNoAutoIdTestEntity.java 2009-12-03 10:23:16 UTC (rev 18120)
@@ -0,0 +1,93 @@
+/*
+ * 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.test.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+public class IntNoAutoIdTestEntity {
+ @Id
+ private Integer id;
+
+ @Audited
+ private Integer number;
+
+ public IntNoAutoIdTestEntity() {
+ }
+
+ public IntNoAutoIdTestEntity(Integer number, Integer id) {
+ this.id = id;
+ this.number = number;
+ }
+
+ public IntNoAutoIdTestEntity(Integer number) {
+ this.number = number;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Integer getNumber() {
+ return number;
+ }
+
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof IntNoAutoIdTestEntity)) return false;
+
+ IntNoAutoIdTestEntity that = (IntNoAutoIdTestEntity) o;
+
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ //noinspection RedundantIfStatement
+ if (number != null ? !number.equals(that.number) : that.number != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (number != null ? number.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "INATE(id = " + id + ", number = " + number + ")";
+ }
+}
\ No newline at end of file
Added: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/WhereJoinTableEntity.java 2009-12-03 10:23:16 UTC (rev 18120)
@@ -0,0 +1,96 @@
+package org.hibernate.envers.test.entities.manytomany;
+
+import org.hibernate.envers.Audited;
+import org.hibernate.envers.test.entities.IntNoAutoIdTestEntity;
+import org.hibernate.annotations.WhereJoinTable;
+
+import javax.persistence.*;
+import java.util.List;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Audited
+public class WhereJoinTableEntity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ private String data;
+
+ @ManyToMany
+ @JoinTable(
+ name = "wjte_ite_join",
+ joinColumns = @JoinColumn(name = "wjte_id"),
+ inverseJoinColumns = @JoinColumn(name = "ite_id")
+ )
+ @WhereJoinTable(clause = "ite_id < 20")
+ private List<IntNoAutoIdTestEntity> references1;
+
+ @ManyToMany
+ @JoinTable(
+ name = "wjte_ite_join",
+ joinColumns = @JoinColumn(name = "wjte_id"),
+ inverseJoinColumns = @JoinColumn(name = "ite_id")
+ )
+ @WhereJoinTable(clause = "ite_id >= 20")
+ private List<IntNoAutoIdTestEntity> references2;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public List<IntNoAutoIdTestEntity> getReferences1() {
+ return references1;
+ }
+
+ public void setReferences1(List<IntNoAutoIdTestEntity> references1) {
+ this.references1 = references1;
+ }
+
+ public List<IntNoAutoIdTestEntity> getReferences2() {
+ return references2;
+ }
+
+ public void setReferences2(List<IntNoAutoIdTestEntity> references2) {
+ this.references2 = references2;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ WhereJoinTableEntity that = (WhereJoinTableEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "WJTE(id = " + id + ", data = " + data + ")";
+ }
+}
Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java (from rev 18113, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicList.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/BasicWhereJoinTable.java 2009-12-03 10:23:16 UTC (rev 18120)
@@ -0,0 +1,186 @@
+/*
+ * 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.test.integration.manytomany;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.entities.IntNoAutoIdTestEntity;
+import org.hibernate.envers.test.entities.manytomany.WhereJoinTableEntity;
+import org.hibernate.envers.test.tools.TestTools;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicWhereJoinTable extends AbstractEntityTest {
+ private Integer ite1_1_id;
+ private Integer ite1_2_id;
+ private Integer ite2_1_id;
+ private Integer ite2_2_id;
+
+ private Integer wjte1_id;
+ private Integer wjte2_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(WhereJoinTableEntity.class);
+ cfg.addAnnotatedClass(IntNoAutoIdTestEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ IntNoAutoIdTestEntity ite1_1 = new IntNoAutoIdTestEntity(1, 10);
+ IntNoAutoIdTestEntity ite1_2 = new IntNoAutoIdTestEntity(1, 11);
+ IntNoAutoIdTestEntity ite2_1 = new IntNoAutoIdTestEntity(2, 20);
+ IntNoAutoIdTestEntity ite2_2 = new IntNoAutoIdTestEntity(2, 21);
+
+ WhereJoinTableEntity wjte1 = new WhereJoinTableEntity();
+ wjte1.setData("wjte1");
+
+ WhereJoinTableEntity wjte2 = new WhereJoinTableEntity();
+ wjte1.setData("wjte2");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(ite1_1);
+ em.persist(ite1_2);
+ em.persist(ite2_1);
+ em.persist(ite2_2);
+ em.persist(wjte1);
+ em.persist(wjte2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 2 (wjte1: 1_1, 2_1)
+
+ em.getTransaction().begin();
+
+ wjte1 = em.find(WhereJoinTableEntity.class, wjte1.getId());
+
+ wjte1.getReferences1().add(ite1_1);
+ wjte1.getReferences2().add(ite2_1);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 3 (wjte1: 1_1, 2_1; wjte2: 1_1, 1_2)
+ em.getTransaction().begin();
+
+ wjte2 = em.find(WhereJoinTableEntity.class, wjte2.getId());
+
+ wjte2.getReferences1().add(ite1_1);
+ wjte2.getReferences1().add(ite1_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ // Revision 4 (wjte1: 2_1; wjte2: 1_1, 1_2, 2_2)
+ em.getTransaction().begin();
+
+ wjte1 = em.find(WhereJoinTableEntity.class, wjte1.getId());
+ wjte2 = em.find(WhereJoinTableEntity.class, wjte2.getId());
+
+ wjte1.getReferences1().remove(ite1_1);
+ wjte2.getReferences2().add(ite2_2);
+
+ em.getTransaction().commit();
+ em.clear();
+
+ //
+
+ ite1_1_id = ite1_1.getId();
+ ite1_2_id = ite1_2.getId();
+ ite2_1_id = ite2_1.getId();
+ ite2_2_id = ite2_2.getId();
+
+ wjte1_id = wjte1.getId();
+ wjte2_id = wjte2.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assertEquals(Arrays.asList(1, 2, 4), getAuditReader().getRevisions(WhereJoinTableEntity.class, wjte1_id));
+ assertEquals(Arrays.asList(1, 3, 4), getAuditReader().getRevisions(WhereJoinTableEntity.class, wjte2_id));
+
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite1_1_id));
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite1_2_id));
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite2_1_id));
+ assertEquals(Arrays.asList(1), getAuditReader().getRevisions(IntNoAutoIdTestEntity.class, ite2_2_id));
+ }
+
+ @Test
+ public void testHistoryOfWjte1() {
+ IntNoAutoIdTestEntity ite1_1 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite1_1_id);
+ IntNoAutoIdTestEntity ite2_1 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite2_1_id);
+
+ WhereJoinTableEntity rev1 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 1);
+ WhereJoinTableEntity rev2 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 2);
+ WhereJoinTableEntity rev3 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 3);
+ WhereJoinTableEntity rev4 = getAuditReader().find(WhereJoinTableEntity.class, wjte1_id, 4);
+
+ // Checking 1st list
+ assert TestTools.checkList(rev1.getReferences1());
+ assert TestTools.checkList(rev2.getReferences1(), ite1_1);
+ assert TestTools.checkList(rev3.getReferences1(), ite1_1);
+ assert TestTools.checkList(rev4.getReferences1());
+
+ // Checking 2nd list
+ assert TestTools.checkList(rev1.getReferences2());
+ assert TestTools.checkList(rev2.getReferences2(), ite2_1);
+ assert TestTools.checkList(rev3.getReferences2(), ite2_1);
+ assert TestTools.checkList(rev4.getReferences2(), ite2_1);
+ }
+
+ @Test
+ public void testHistoryOfWjte2() {
+ IntNoAutoIdTestEntity ite1_1 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite1_1_id);
+ IntNoAutoIdTestEntity ite1_2 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite1_2_id);
+ IntNoAutoIdTestEntity ite2_2 = getEntityManager().find(IntNoAutoIdTestEntity.class, ite2_2_id);
+
+ WhereJoinTableEntity rev1 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 1);
+ WhereJoinTableEntity rev2 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 2);
+ WhereJoinTableEntity rev3 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 3);
+ WhereJoinTableEntity rev4 = getAuditReader().find(WhereJoinTableEntity.class, wjte2_id, 4);
+
+ // Checking 1st list
+ assert TestTools.checkList(rev1.getReferences1());
+ assert TestTools.checkList(rev2.getReferences1());
+ assert TestTools.checkList(rev3.getReferences1(), ite1_1, ite1_2);
+ assert TestTools.checkList(rev4.getReferences1(), ite1_1, ite1_2);
+
+ // Checking 2nd list
+ assert TestTools.checkList(rev1.getReferences2());
+ assert TestTools.checkList(rev2.getReferences2());
+ assert TestTools.checkList(rev3.getReferences2());
+ assert TestTools.checkList(rev4.getReferences2(), ite2_2);
+ }
+}
\ No newline at end of file
15 years
Hibernate SVN: r18119 - core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access.
by hibernate-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2009-12-03 04:03:35 -0500 (Thu, 03 Dec 2009)
New Revision: 18119
Modified:
core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java
Log:
[HHH-4575] (When Infinispan is configured for INVALIDATION don't send cluster message on entity insert) Fixed.
Modified: core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java
===================================================================
--- core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java 2009-12-03 09:03:31 UTC (rev 18118)
+++ core/trunk/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/access/TransactionalAccessDelegate.java 2009-12-03 09:03:35 UTC (rev 18119)
@@ -32,6 +32,7 @@
import org.hibernate.cache.infinispan.impl.BaseRegion;
import org.hibernate.cache.infinispan.util.CacheAdapter;
import org.hibernate.cache.infinispan.util.CacheHelper;
+import org.hibernate.cache.infinispan.util.FlagAdapter;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -109,7 +110,12 @@
public boolean insert(Object key, Object value, Object version) throws CacheException {
if (!region.checkValid())
return false;
- cacheAdapter.put(key, value);
+
+ if (cacheAdapter.isClusteredInvalidation())
+ cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL).put(key, value);
+ else
+ cacheAdapter.put(key, value);
+
return true;
}
15 years
Hibernate SVN: r18118 - in core/trunk/envers/src: main/java/org/hibernate/envers/configuration/metadata and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-12-03 04:03:31 -0500 (Thu, 03 Dec 2009)
New Revision: 18118
Added:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java
core/trunk/envers/src/test/resources/hibernate.test.cfg.xml
Log:
HHH-4634:
- adding a register of all audit entity names generated so far
- generating a unique entity name in case of a relation owned by both sides
- fixing the test
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/EntitiesConfigurator.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -41,6 +41,7 @@
import org.hibernate.envers.configuration.metadata.EntityXmlMappingData;
import org.hibernate.envers.configuration.metadata.reader.ClassAuditingData;
import org.hibernate.envers.configuration.metadata.AuditMetadataGenerator;
+import org.hibernate.envers.configuration.metadata.AuditEntityNameRegister;
import org.hibernate.envers.entities.EntitiesConfigurations;
import org.hibernate.envers.tools.StringTools;
import org.hibernate.envers.tools.graph.GraphTopologicalSort;
@@ -57,8 +58,11 @@
public EntitiesConfigurations configure(Configuration cfg, ReflectionManager reflectionManager,
GlobalConfiguration globalCfg, AuditEntitiesConfiguration verEntCfg,
Document revisionInfoXmlMapping, Element revisionInfoRelationMapping) {
+ // Creating a name register to capture all audit entity names created.
+ AuditEntityNameRegister auditEntityNameRegister = new AuditEntityNameRegister();
+
AuditMetadataGenerator auditMetaGen = new AuditMetadataGenerator(cfg, globalCfg, verEntCfg,
- revisionInfoRelationMapping);
+ revisionInfoRelationMapping, auditEntityNameRegister);
DOMWriter writer = new DOMWriter();
// Sorting the persistent class topologically - superclass always before subclass
@@ -76,6 +80,7 @@
new AnnotationsMetadataReader(globalCfg, reflectionManager, pc);
ClassAuditingData auditData = annotationsMetadataReader.getAuditData();
+ EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
if (auditData.isAudited()) {
pcDatas.put(pc, auditData);
@@ -83,14 +88,12 @@
verEntCfg.addCustomAuditTableName(pc.getEntityName(), auditData.getAuditTable().value());
}
- EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
auditMetaGen.generateFirstPass(pc, auditData, xmlMappingData, true);
- xmlMappings.put(pc, xmlMappingData);
} else {
- EntityXmlMappingData xmlMappingData = new EntityXmlMappingData();
auditMetaGen.generateFirstPass(pc, auditData, xmlMappingData, false);
- xmlMappings.put(pc, xmlMappingData);
}
+
+ xmlMappings.put(pc, xmlMappingData);
}
// Second pass
Added: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditEntityNameRegister.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -0,0 +1,50 @@
+package org.hibernate.envers.configuration.metadata;
+
+import org.hibernate.MappingException;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * A register of all audit entity names used so far.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditEntityNameRegister {
+ private final Set<String> auditEntityNames = new HashSet<String>();
+
+ /**
+ * @param auditEntityName Name of the audit entity.
+ * @return True if the given audit entity name is already used.
+ */
+ private boolean check(String auditEntityName) {
+ return auditEntityNames.contains(auditEntityName);
+ }
+
+ /**
+ * Register an audit entity name. If the name is already registered, an exception is thrown.
+ * @param auditEntityName Name of the audit entity.
+ */
+ public void register(String auditEntityName) {
+ if (auditEntityNames.contains(auditEntityName)) {
+ throw new MappingException("The audit entity name '" + auditEntityName + "' is already registered.");
+ }
+
+ auditEntityNames.add(auditEntityName);
+ }
+
+ /**
+ * Creates a unique (not yet registered) audit entity name by appending consecutive numbers to the base
+ * name. If the base name is not yet used, it is returned unmodified.
+ * @param baseAuditEntityName The base entity name.
+ * @return
+ */
+ public String createUnique(final String baseAuditEntityName) {
+ String auditEntityName = baseAuditEntityName;
+ int count = 1;
+ while (check(auditEntityName)) {
+ auditEntityName = baseAuditEntityName + count++;
+ }
+
+ return auditEntityName;
+ }
+}
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -69,12 +69,15 @@
private final Map<String, EntityConfiguration> entitiesConfigurations;
private final Map<String, EntityConfiguration> notAuditedEntitiesConfigurations;
+ private final AuditEntityNameRegister auditEntityNameRegister;
+
// Map entity name -> (join descriptor -> element describing the "versioned" join)
private final Map<String, Map<Join, Element>> entitiesJoins;
public AuditMetadataGenerator(Configuration cfg, GlobalConfiguration globalCfg,
AuditEntitiesConfiguration verEntCfg,
- Element revisionInfoRelationMapping) {
+ Element revisionInfoRelationMapping,
+ AuditEntityNameRegister auditEntityNameRegister) {
this.cfg = cfg;
this.globalCfg = globalCfg;
this.verEntCfg = verEntCfg;
@@ -85,6 +88,8 @@
this.idMetadataGenerator = new IdMetadataGenerator(this);
this.toOneRelationMetadataGenerator = new ToOneRelationMetadataGenerator(this);
+ this.auditEntityNameRegister = auditEntityNameRegister;
+
entitiesConfigurations = new HashMap<String, EntityConfiguration>();
notAuditedEntitiesConfigurations = new HashMap<String, EntityConfiguration>();
entitiesJoins = new HashMap<String, Map<Join, Element>>();
@@ -344,6 +349,9 @@
String auditEntityName = verEntCfg.getAuditEntityName(entityName);
String auditTableName = verEntCfg.getAuditTableName(entityName, pc.getTable().getName());
+ // Registering the audit entity name, now that it is known
+ auditEntityNameRegister.register(auditEntityName);
+
AuditTableData auditTableData = new AuditTableData(auditEntityName, auditTableName, schema, catalog);
// Generating a mapping for the id
@@ -446,6 +454,10 @@
return verEntCfg;
}
+ AuditEntityNameRegister getAuditEntityNameRegister() {
+ return auditEntityNameRegister;
+ }
+
void throwUnsupportedTypeException(Type type, String entityName, String propertyName) {
String message = "Type not supported for auditing: " + type.getClass().getName() +
", on entity " + entityName + ", property '" + propertyName + "'.";
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -254,7 +254,13 @@
// Generating the XML mapping for the middle entity, only if the relation isn't inverse.
// If the relation is inverse, will be later checked by comparing middleEntityXml with null.
Element middleEntityXml;
- if (!propertyValue.isInverse()) {
+ if (!propertyValue.isInverse()) {
+ // Generating a unique middle entity name
+ auditMiddleEntityName = mainGenerator.getAuditEntityNameRegister().createUnique(auditMiddleEntityName);
+
+ // Registering the generated name
+ mainGenerator.getAuditEntityNameRegister().register(auditMiddleEntityName);
+
middleEntityXml = createMiddleEntityXml(auditMiddleTableName, auditMiddleEntityName);
} else {
middleEntityXml = null;
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -68,6 +68,15 @@
return prop_mapping;
}
+ private static void addOrModifyAttribute(Element parent, String name, String value) {
+ Attribute attribute = parent.attribute(name);
+ if (attribute == null) {
+ parent.addAttribute(name, value);
+ } else {
+ attribute.setValue(value);
+ }
+ }
+
public static Element addOrModifyColumn(Element parent, String name) {
Element column_mapping = parent.element("column");
@@ -76,12 +85,7 @@
}
if (!StringTools.isEmpty(name)) {
- Attribute nameAttribute = column_mapping.attribute("name");
- if (nameAttribute == null) {
- column_mapping.addAttribute("name", name);
- } else {
- nameAttribute.setValue(name);
- }
+ addOrModifyAttribute(column_mapping, "name", name);
}
return column_mapping;
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning1Entity.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -36,7 +36,8 @@
@Entity
@Audited
public class ListBiowning1Entity {
- @Id
+ @Id
+ @GeneratedValue
private Integer id;
private String data;
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/entities/manytomany/biowned/ListBiowning2Entity.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -37,6 +37,7 @@
@Audited
public class ListBiowning2Entity {
@Id
+ @GeneratedValue
private Integer id;
private String data;
Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/biowned/BasicBiowned.java 2009-12-03 09:03:31 UTC (rev 18118)
@@ -30,6 +30,7 @@
import org.hibernate.envers.test.tools.TestTools;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
+import static org.testng.Assert.assertEquals;
import javax.persistence.EntityManager;
import java.util.Arrays;
@@ -44,11 +45,11 @@
private Integer o2_2_id;
public void configure(Ejb3Configuration cfg) {
- //cfg.addAnnotatedClass(ListBiowning1Entity.class);
- //cfg.addAnnotatedClass(ListBiowning2Entity.class);
+ cfg.addAnnotatedClass(ListBiowning1Entity.class);
+ cfg.addAnnotatedClass(ListBiowning2Entity.class);
}
- //@BeforeClass(dependsOnMethods = "init")
+ @BeforeClass(dependsOnMethods = "init")
public void initData() {
EntityManager em = getEntityManager();
@@ -66,6 +67,7 @@
em.persist(o2_2);
em.getTransaction().commit();
+ em.clear();
// Revision 2 (1_1 <-> 2_1; 1_2 <-> 2_2)
@@ -80,6 +82,7 @@
o1_2.getReferences().add(o2_2);
em.getTransaction().commit();
+ em.clear();
// Revision 3 (1_1 <-> 2_1, 2_2; 1_2 <-> 2_2)
em.getTransaction().begin();
@@ -90,8 +93,9 @@
o1_1.getReferences().add(o2_2);
em.getTransaction().commit();
+ em.clear();
- // Revision 4 (1_1 <-> 2_1; 1_2 <-> 2_1)
+ // Revision 4 (1_2 <-> 2_1, 2_2)
em.getTransaction().begin();
o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
@@ -101,11 +105,12 @@
o2_2.getReferences().remove(o1_1);
o2_1.getReferences().remove(o1_1);
- o1_2.getReferences().add(o2_1);
+ o2_1.getReferences().add(o1_2);
em.getTransaction().commit();
+ em.clear();
- // Revision 5 (1_2 <-> 2_1, 2_2)
+ // Revision 5 (1_1 <-> 2_2, 1_2 <-> 2_2)
em.getTransaction().begin();
o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
@@ -113,12 +118,11 @@
o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());
- o2_1.getReferences().remove(o1_1);
- o1_1.getReferences().remove(o2_1);
- o1_2.getReferences().add(o2_2);
- o2_2.getReferences().add(o1_2);
+ o1_2.getReferences().remove(o2_1);
+ o1_1.getReferences().add(o2_2);
em.getTransaction().commit();
+ em.clear();
//
@@ -128,16 +132,20 @@
o2_2_id = o2_2.getId();
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testRevisionsCounts() {
- assert Arrays.asList(1, 2, 3, 4, 5).equals(getAuditReader().getRevisions(ListBiowning1Entity.class, o1_1_id));
- assert Arrays.asList(1, 2, 4, 5).equals(getAuditReader().getRevisions(ListBiowning1Entity.class, o1_2_id));
+ // Although it would seem that when modifying references both entities should be marked as modified, because
+ // ownly the owning side is notified (because of the bi-owning mapping), a revision is created only for
+ // the entity where the collection was directly modified.
- assert Arrays.asList(1, 2, 4, 5).equals(getAuditReader().getRevisions(ListBiowning2Entity.class, o2_1_id));
- assert Arrays.asList(1, 2, 3, 4, 5).equals(getAuditReader().getRevisions(ListBiowning2Entity.class, o2_2_id));
+ assertEquals(Arrays.asList(1, 2, 3, 5), getAuditReader().getRevisions(ListBiowning1Entity.class, o1_1_id));
+ assertEquals(Arrays.asList(1, 2, 5), getAuditReader().getRevisions(ListBiowning1Entity.class, o1_2_id));
+
+ assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_1_id));
+ assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_2_id));
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfO1_1() {
ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
@@ -151,11 +159,11 @@
assert TestTools.checkList(rev1.getReferences());
assert TestTools.checkList(rev2.getReferences(), o2_1);
assert TestTools.checkList(rev3.getReferences(), o2_1, o2_2);
- assert TestTools.checkList(rev4.getReferences(), o2_1);
- assert TestTools.checkList(rev5.getReferences());
+ assert TestTools.checkList(rev4.getReferences());
+ assert TestTools.checkList(rev5.getReferences(), o2_2);
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfO1_2() {
ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);
@@ -169,11 +177,12 @@
assert TestTools.checkList(rev1.getReferences());
assert TestTools.checkList(rev2.getReferences(), o2_2);
assert TestTools.checkList(rev3.getReferences(), o2_2);
- assert TestTools.checkList(rev4.getReferences(), o2_1);
- assert TestTools.checkList(rev5.getReferences(), o2_1, o2_2);
+ assert TestTools.checkList(rev4.getReferences(), o2_1, o2_2);
+ System.out.println("rev5.getReferences() = " + rev5.getReferences());
+ assert TestTools.checkList(rev5.getReferences(), o2_2);
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfO2_1() {
ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
@@ -187,11 +196,11 @@
assert TestTools.checkList(rev1.getReferences());
assert TestTools.checkList(rev2.getReferences(), o1_1);
assert TestTools.checkList(rev3.getReferences(), o1_1);
- assert TestTools.checkList(rev4.getReferences(), o1_1, o1_2);
- assert TestTools.checkList(rev5.getReferences(), o1_2);
+ assert TestTools.checkList(rev4.getReferences(), o1_2);
+ assert TestTools.checkList(rev5.getReferences());
}
- @Test(enabled = false)
+ @Test(enabled = true)
public void testHistoryOfO2_2() {
ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);
@@ -205,7 +214,7 @@
assert TestTools.checkList(rev1.getReferences());
assert TestTools.checkList(rev2.getReferences(), o1_2);
assert TestTools.checkList(rev3.getReferences(), o1_1, o1_2);
- assert TestTools.checkList(rev4.getReferences());
- assert TestTools.checkList(rev5.getReferences(), o1_2);
+ assert TestTools.checkList(rev4.getReferences(), o1_2);
+ assert TestTools.checkList(rev5.getReferences(), o1_1, o1_2);
}
}
\ No newline at end of file
Modified: core/trunk/envers/src/test/resources/hibernate.test.cfg.xml
===================================================================
--- core/trunk/envers/src/test/resources/hibernate.test.cfg.xml 2009-12-03 09:02:31 UTC (rev 18117)
+++ core/trunk/envers/src/test/resources/hibernate.test.cfg.xml 2009-12-03 09:03:31 UTC (rev 18118)
@@ -17,13 +17,13 @@
<property name="connection.username">sa</property>
<property name="connection.password"></property>
- <!--<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
- <property name="connection.url">jdbc:mysql:///hibernate_tests?useUnicode=true&characterEncoding=UTF-8</property>
- <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
- <property name="connection.username">root</property>
- <property name="connection.password"></property>
+ <!--<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>-->
+ <!--<property name="connection.url">jdbc:mysql:///hibernate_tests?useUnicode=true&characterEncoding=UTF-8</property>-->
+ <!--<property name="connection.driver_class">com.mysql.jdbc.Driver</property>-->
+ <!--<property name="connection.username">root</property>-->
+ <!--<property name="connection.password"></property>-->
- <property name="hibernate.jdbc.batch_size">100</property>-->
+ <!--<property name="hibernate.jdbc.batch_size">100</property>-->
<!--<event type="post-insert">
<listener class="org.hibernate.envers.event.AuditEventListener" />
15 years