Log Message
Support Hibernate Envers (XSTR-743). Update Hibernate versions.
Modified Paths
- trunk/pom.xml
- trunk/xstream-distribution/src/content/changes.html
- trunk/xstream-distribution/src/content/download.html
- trunk/xstream-distribution/src/content/faq.html
- trunk/xstream-distribution/src/content/team.html
- trunk/xstream-hibernate/pom.xml
- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java
- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java
- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java
- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedSetConverter.java
- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/mapper/HibernateMapper.java
- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/package.html
- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java
Diff
Modified: trunk/pom.xml (2106 => 2107)
--- trunk/pom.xml 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/pom.xml 2013-09-03 19:52:52 UTC (rev 2107)
@@ -66,7 +66,7 @@
</activation>
<properties>
<version.hsqldb>1.8.0.10</version.hsqldb>
- <version.org.hibernate.core>3.3.2.GA</version.org.hibernate.core>
+ <version.org.hibernate.core>3.6.6.Final</version.org.hibernate.core>
</properties>
</profile>
<profile>
@@ -82,6 +82,7 @@
<!-- repeat Hibernate version dependencies, JDK intervals in activation is not supported with M2.0.x -->
<version.hsqldb>1.8.0.10</version.hsqldb>
<version.org.hibernate.core>3.3.2.GA</version.org.hibernate.core>
+ <version.org.hibernate.envers>3.6.6.Final</version.org.hibernate.envers><!-- not usable with JDK 1.4 -->
</properties>
</profile>
</profiles>
@@ -271,6 +272,17 @@
<version>${version.org.hibernate.core}</version>
</dependency>
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-envers</artifactId>
+ <version>${version.org.hibernate.envers}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${version.hsqldb}</version>
@@ -642,7 +654,8 @@
<version.net.sf.kxml.kxml2>2.3.0</version.net.sf.kxml.kxml2>
<version.org.codehaus.jettison>1.2</version.org.codehaus.jettison>
<version.org.codehaus.woodstox.asl>3.2.7</version.org.codehaus.woodstox.asl>
- <version.org.hibernate.core>4.1.4.Final</version.org.hibernate.core>
+ <version.org.hibernate.core>4.2.5.Final</version.org.hibernate.core>
+ <version.org.hibernate.envers>${version.org.hibernate.core}</version.org.hibernate.envers>
<version.org.jdom>1.1.3</version.org.jdom>
<version.org.jdom2>2.0.5</version.org.jdom2>
<version.org.json>20080701</version.org.json>
Modified: trunk/xstream-distribution/src/content/changes.html (2106 => 2107)
--- trunk/xstream-distribution/src/content/changes.html 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-distribution/src/content/changes.html 2013-09-03 19:52:52 UTC (rev 2107)
@@ -79,6 +79,7 @@
<li>JIRA:XSTR-578: Implement support for aliasing in JavaClasConverter, JavaFieldConverter and
JavaMethodConverter. While it is not possible to enable this in general, new constructors have been added to
these converters and an example in the acceptance tests (AliasTest).</li>
+ <li>JIRA:XSTR-743: Support proxy collections of Hibernate Envers.</li>
</ul>
<h2>API changes</h2>
Modified: trunk/xstream-distribution/src/content/download.html (2106 => 2107)
--- trunk/xstream-distribution/src/content/download.html 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-distribution/src/content/download.html 2013-09-03 19:52:52 UTC (rev 2107)
@@ -84,10 +84,17 @@
<ul>
<li>Supported Hibernate versions:
<ul>
- <li><a href="" 4.1.4</a>, for Java 6 or higher.</li>
- <li><a href="" 3.3.2</a>, up to Java 5.</li>
+ <li><a href="" Core 4.2.5</a>, for Java 6 or higher.</li>
+ <li><a href="" Core 3.6.6</a>, for Java 5.</li>
+ <li><a href="" Core 3.3.2</a>, for Java 1.4.</li>
</ul>
</li>
+ <li>Supported Hibernate Envers versions:
+ <ul>
+ <li><a href="" Envers 4.2.5</a>, for Java 6 or higher.</li>
+ <li><a href="" Envers 3.6.6</a>, for Java 5.</li>
+ </ul>
+ </li>
</ul>
</body>
Modified: trunk/xstream-distribution/src/content/faq.html (2106 => 2107)
--- trunk/xstream-distribution/src/content/faq.html 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-distribution/src/content/faq.html 2013-09-03 19:52:52 UTC (rev 2107)
@@ -320,6 +320,11 @@
</pre></div>
<!-- ...................................................... -->
+ <h2 id="Serialization_Hibernate_Envers">Does XStream's Hibernate package support Envers?</h2>
+ <p>Yes. Hibernate Envers is an optional dependency for XStream and it is automatically supported by XStream's
+ Hibernate package when the proxy collection types of Envers are available on the classpath.</p>
+
+ <!-- ...................................................... -->
<h2 id="Serialization_system_attributes">My attributes are interpreted by XStream itself and cause unexpected behavior</h2>
<p>XStream's generic converters and the marshalling strategies use a number of attributes on their own. Especially the attributes named
<em>id</em>, <em>class</em> and <em>reference</em> are likely to cause such collisions. Main reason is XStream's history, because
Modified: trunk/xstream-distribution/src/content/team.html (2106 => 2107)
--- trunk/xstream-distribution/src/content/team.html 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-distribution/src/content/team.html 2013-09-03 19:52:52 UTC (rev 2107)
@@ -116,6 +116,7 @@
<li>Nikita Levyankov</li>
<li>Kohsuke Kawaguchi</li>
<li>Peter Abeles</li>
+ <li>Edison Guo</li>
</ul>
<p>Please direct all correspondence about XStream to the <a href="" mailing lists</a>
Modified: trunk/xstream-hibernate/pom.xml (2106 => 2107)
--- trunk/xstream-hibernate/pom.xml 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/pom.xml 2013-09-03 19:52:52 UTC (rev 2107)
@@ -103,7 +103,7 @@
<configuration>
<outputDirectory>target/dependencies</outputDirectory>
<includeScope>runtime</includeScope>
- <excludeArtifactIds>xstream,kxml2-min</excludeArtifactIds>
+ <excludeArtifactIds>xstream,xpp3_min,xmlpull</excludeArtifactIds>
</configuration>
</execution>
</executions>
@@ -159,7 +159,14 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
+ <!-- -->
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-envers</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <!-- -->
+ <dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java (2106 => 2107)
--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java 2013-09-03 19:52:52 UTC (rev 2107)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -19,9 +19,9 @@
/**
- * A converter for Hibernate's PersistentBag, PersistentList and PersistentSet. The converter
- * will drop any reference to the Hibernate collection and emit at serialization time an
- * equivalent JDK collection instead.
+ * A converter for Hibernate's PersistentBag, PersistentList and PersistentSet and for ListProxy
+ * and SetProxy from Hibernate's Envers add-on. The converter will drop any reference to the
+ * Hibernate collection and emit at serialization time an equivalent JDK collection instead.
*
* @author Jörg Schaible
* @since 1.4
@@ -39,9 +39,14 @@
}
public boolean canConvert(final Class type) {
- return type == Hibernate.PersistentBag
- || type == Hibernate.PersistentList
- || type == Hibernate.PersistentSet;
+ return type != null
+ && (
+ type == Hibernate.PersistentBag
+ || type == Hibernate.PersistentList
+ || type == Hibernate.PersistentSet
+ || type == Hibernate.EnversList
+ || type == Hibernate.EnversSet
+ );
}
public Object unmarshal(final HierarchicalStreamReader reader,
Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java (2106 => 2107)
--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java 2013-09-03 19:52:52 UTC (rev 2107)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -19,8 +19,9 @@
/**
- * A converter for Hibernate's PersistentMap. The converter will drop any reference to the
- * Hibernate collection and emit at serialization time an equivalent JDK collection instead.
+ * A converter for Hibernate's PersistentMap and for the MapProxy from Hibernate's Envers
+ * add-on. The converter will drop any reference to the Hibernate collection and emit at
+ * serialization time an equivalent JDK collection instead.
*
* @author Jörg Schaible
* @since 1.4
@@ -38,7 +39,7 @@
}
public boolean canConvert(final Class type) {
- return type == Hibernate.PersistentMap;
+ return type != null && (type == Hibernate.PersistentMap || type == Hibernate.EnversMap);
}
public Object unmarshal(final HierarchicalStreamReader reader,
Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java (2106 => 2107)
--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java 2013-09-03 19:52:52 UTC (rev 2107)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -19,8 +19,9 @@
/**
- * A converter for Hibernate's PersistentSortedMap. The converter will drop any reference to the
- * Hibernate collection and emit at serialization time an equivalent JDK collection instead.
+ * A converter for Hibernate's PersistentSortedMap and for the SortedMapProxy from Hibernate's
+ * Envers add-on. The converter will drop any reference to the Hibernate collection and emit at
+ * serialization time an equivalent JDK collection instead.
*
* @author Jörg Schaible
* @since 1.4
@@ -38,7 +39,7 @@
}
public boolean canConvert(final Class type) {
- return type == Hibernate.PersistentSortedMap;
+ return type != null && (type == Hibernate.PersistentSortedMap || type == Hibernate.EnversSortedMap);
}
public Object unmarshal(final HierarchicalStreamReader reader,
Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedSetConverter.java (2106 => 2107)
--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedSetConverter.java 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedSetConverter.java 2013-09-03 19:52:52 UTC (rev 2107)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -19,8 +19,9 @@
/**
- * A converter for Hibernate's PersistentSortedSet. The converter will drop any reference to the
- * Hibernate collection and emit at serialization time an equivalent JDK collection instead.
+ * A converter for Hibernate's PersistentSortedSet and for the SortedSetProxy from Hibernate's
+ * Envers add-on. The converter will drop any reference to the Hibernate collection and emit at
+ * serialization time an equivalent JDK collection instead.
*
* @author Jörg Schaible
* @since 1.4
@@ -38,7 +39,7 @@
}
public boolean canConvert(final Class type) {
- return type == Hibernate.PersistentSortedSet;
+ return type != null && (type == Hibernate.PersistentSortedSet || type == Hibernate.EnversSortedSet);
}
public Object unmarshal(final HierarchicalStreamReader reader,
Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/mapper/HibernateMapper.java (2106 => 2107)
--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/mapper/HibernateMapper.java 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/mapper/HibernateMapper.java 2013-09-03 19:52:52 UTC (rev 2107)
@@ -24,9 +24,9 @@
/**
- * Mapper for Hibernate types. It will map the class names of the Hibernate collections with
- * equivalents of the JDK at serialization time. It will also map the names of the proxy types
- * to the names of the proxies element's type.
+ * Mapper for Hibernate types. It will map the class names of the Hibernate collections and
+ * Envers collection proxies with equivalents of the JDK at serialization time. It will also map
+ * the names of the proxy types to the names of the proxies element's type.
*
* @author Konstantin Pribluda
* @author Jörg Schaible
@@ -44,6 +44,12 @@
collectionMap.put(Hibernate.PersistentSet, HashSet.class);
collectionMap.put(Hibernate.PersistentSortedMap, TreeMap.class);
collectionMap.put(Hibernate.PersistentSortedSet, TreeSet.class);
+ collectionMap.put(Hibernate.EnversList, ArrayList.class);
+ collectionMap.put(Hibernate.EnversMap, HashMap.class);
+ collectionMap.put(Hibernate.EnversSet, HashSet.class);
+ collectionMap.put(Hibernate.EnversSortedMap, TreeMap.class);
+ collectionMap.put(Hibernate.EnversSortedSet, TreeSet.class);
+ collectionMap.remove(null);
}
public Class defaultImplementationOf(final Class clazz) {
@@ -56,15 +62,14 @@
public String serializedClass(final Class clazz) {
if (clazz != null) {
+ if (collectionMap.containsKey(clazz)) {
+ // Pretend this is the underlying collection class and map that instead
+ return super.serializedClass((Class)collectionMap.get(clazz));
+ }
// check whether we are Hibernate proxy and substitute real name
if (HibernateProxy.class.isAssignableFrom(clazz)) {
return super.serializedClass(clazz.getSuperclass());
}
-
- if (collectionMap.containsKey(clazz)) {
- // Pretend this is the underlying collection class and map that instead
- return super.serializedClass((Class)collectionMap.get(clazz));
- }
}
return super.serializedClass(clazz);
}
Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/package.html (2106 => 2107)
--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/package.html 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/package.html 2013-09-03 19:52:52 UTC (rev 2107)
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2011 XStream committers.
+ Copyright (C) 2011, 2013 XStream committers.
All rights reserved.
The software in this package is published under the terms of the BSD
@@ -9,9 +9,10 @@
Created on 11. August 2011 by Joerg Schaible
-->
<body>
-<p>Support of Hibernate enhanced collections and proxied types.
-To drop the internals of Hibernate when marshalling such objects to XStream,
-all converters and the mapper has to be registered for the XStream instance:</p>
+<p>Support of Hibernate enhanced collections and proxied types and Hibernate's
+collection proxies from the Envers add-on. To drop the internals of Hibernate
+when marshalling such objects to XStream, all converters and the mapper have to
+be registered for the XStream instance:</p>
<p><code><pre>final XStream xstream = new XStream() {
protected MapperWrapper wrapMapper(final MapperWrapper next) {
return new HibernateMapper(next);
Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java (2106 => 2107)
--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java 2013-08-27 07:21:29 UTC (rev 2106)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java 2013-09-03 19:52:52 UTC (rev 2107)
@@ -1,11 +1,13 @@
/*
- * Copyright (C) 2012 Joerg Schaible.
+ * Copyright (C) 2012, 2013 Joerg Schaible.
* All rights reserved.
*
* Created on 08.06.2012 by Joerg Schaible
*/
package com.thoughtworks.xstream.hibernate.util;
+import com.thoughtworks.xstream.core.JVM;
+
import org.hibernate.proxy.HibernateProxy;
@@ -22,6 +24,11 @@
public final static Class PersistentSet = loadHibernateType("org.hibernate.collection.internal.PersistentSet");
public final static Class PersistentSortedMap = loadHibernateType("org.hibernate.collection.internal.PersistentSortedMap");
public final static Class PersistentSortedSet = loadHibernateType("org.hibernate.collection.internal.PersistentSortedSet");
+ public final static Class EnversList = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.ListProxy");
+ public final static Class EnversMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.MapProxy");
+ public final static Class EnversSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SetProxy");
+ public final static Class EnversSortedMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedMapProxy");
+ public final static Class EnversSortedSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedSetProxy");
private static Class loadHibernateType(String name) {
Class type = null;
@@ -37,4 +44,16 @@
}
return type;
}
+
+ private static Class loadHibernateEnversType(String name) {
+ Class type = null;
+ if (JVM.is15()) {
+ try {
+ type = HibernateProxy.class.getClassLoader().loadClass(name);
+ } catch (ClassNotFoundException e) {
+ // not available
+ }
+ }
+ return type;
+ }
}
To unsubscribe from this list please visit:
