Skip to content

Commit c007b4f

Browse files
committed
Update Hibernate support to latest version of 6.x line.
1 parent 4f670a7 commit c007b4f

File tree

5 files changed

+66
-83
lines changed

5 files changed

+66
-83
lines changed

pom.xml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,6 @@
393393
<artifactId>cglib-nodep</artifactId>
394394
<version>${version.cglib.nodep}</version>
395395
</dependency>
396-
<dependency>
397-
<groupId>javassist</groupId>
398-
<artifactId>javassist</artifactId>
399-
<version>${version.javaassist}</version>
400-
</dependency>
401396

402397
<dependency>
403398
<groupId>org.dom4j</groupId>
@@ -550,38 +545,20 @@
550545
</dependency>
551546

552547
<dependency>
553-
<groupId>org.hibernate</groupId>
548+
<groupId>org.hibernate.orm</groupId>
554549
<artifactId>hibernate-core</artifactId>
555-
<version>${version.org.hibernate.core}</version>
550+
<version>${version.org.hibernate.orm.core}</version>
556551
</dependency>
557552
<dependency>
558-
<groupId>org.hibernate</groupId>
553+
<groupId>org.hibernate.orm</groupId>
559554
<artifactId>hibernate-envers</artifactId>
560-
<version>${version.org.hibernate.envers}</version>
561-
<exclusions>
562-
<exclusion>
563-
<groupId>cglib</groupId>
564-
<artifactId>cglib</artifactId>
565-
</exclusion>
566-
</exclusions>
555+
<version>${version.org.hibernate.orm.envers}</version>
567556
</dependency>
568557
<dependency>
569558
<groupId>org.hsqldb</groupId>
570559
<artifactId>hsqldb</artifactId>
571560
<version>${version.hsqldb}</version>
572561
</dependency>
573-
<dependency>
574-
<groupId>org.slf4j</groupId>
575-
<artifactId>slf4j-api</artifactId>
576-
<version>${version.org.slf4j}</version>
577-
<scope>runtime</scope>
578-
</dependency>
579-
<dependency>
580-
<groupId>org.slf4j</groupId>
581-
<artifactId>slf4j-simple</artifactId>
582-
<version>${version.org.slf4j}</version>
583-
<scope>runtime</scope>
584-
</dependency>
585562

586563
<dependency>
587564
<groupId>org.openjdk.jmh</groupId>
@@ -1109,7 +1086,6 @@
11091086
<version.hsqldb>2.2.8</version.hsqldb>
11101087
<version.io.github.x-stream.mxparser>1.2.2</version.io.github.x-stream.mxparser>
11111088
<version.jakarta.inject.api>1.0</version.jakarta.inject.api>
1112-
<version.javaassist>3.12.1.GA</version.javaassist>
11131089
<version.javax.activation.api>1.2.0</version.javax.activation.api>
11141090
<version.javax.annotation.api>1.3.2</version.javax.annotation.api>
11151091
<version.javax.xml.bind.api>2.3.1</version.javax.xml.bind.api>
@@ -1122,14 +1098,13 @@
11221098
<version.org.codehaus.jettison>1.5.4</version.org.codehaus.jettison>
11231099
<version.com.fasterxml.woodstox.core>6.4.0</version.com.fasterxml.woodstox.core>
11241100
<version.org.dom4j>2.0.2</version.org.dom4j>
1125-
<version.org.hibernate.core>4.2.5.Final</version.org.hibernate.core>
1126-
<version.org.hibernate.envers>${version.org.hibernate.core}</version.org.hibernate.envers>
1101+
<version.org.hibernate.orm.core>6.6.28.Final</version.org.hibernate.orm.core>
1102+
<version.org.hibernate.orm.envers>${version.org.hibernate.orm.core}</version.org.hibernate.orm.envers>
11271103
<version.org.jdom>1.1.3</version.org.jdom>
11281104
<version.org.jdom2>2.0.6</version.org.jdom2>
11291105
<version.org.json>20180813</version.org.json>
11301106
<version.org.openjdk.jmh>1.21</version.org.openjdk.jmh>
11311107
<version.org.ops4j.pax.exam>4.13.4</version.org.ops4j.pax.exam>
1132-
<version.org.slf4j>1.6.1</version.org.slf4j>
11331108
<version.stax>1.2.0</version.stax>
11341109
<version.xerces.impl>2.8.1</version.xerces.impl>
11351110
<version.xmlpull>1.1.3.1</version.xmlpull>

xstream-hibernate/pom.xml

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
22
<!--
3-
Copyright (C) 2011, 2012, 2013, 2015, 2017, 2018, 2019, 2020, 2022 XStream committers.
3+
Copyright (C) 2011, 2012, 2013, 2015, 2017, 2018, 2019, 2020, 2022, 2025 XStream committers.
44
All rights reserved.
55
66
The software in this package is published under the terms of the BSD
@@ -90,49 +90,43 @@
9090
<artifactId>xstream</artifactId>
9191
</dependency>
9292
<dependency>
93-
<groupId>com.thoughtworks.xstream</groupId>
94-
<artifactId>xstream</artifactId>
95-
<classifier>tests</classifier>
96-
<type>test-jar</type>
93+
<groupId>org.hibernate.orm</groupId>
94+
<artifactId>hibernate-core</artifactId>
95+
<optional>true</optional>
9796
</dependency>
9897
<dependency>
99-
<groupId>org.hibernate</groupId>
100-
<artifactId>hibernate-core</artifactId>
98+
<groupId>org.hibernate.orm</groupId>
99+
<artifactId>hibernate-envers</artifactId>
100+
<optional>true</optional>
101101
</dependency>
102102
<dependency>
103-
<groupId>org.hibernate</groupId>
104-
<artifactId>hibernate-envers</artifactId>
105-
<optional>true</optional>
103+
<groupId>com.thoughtworks.xstream</groupId>
104+
<artifactId>xstream</artifactId>
105+
<classifier>tests</classifier>
106+
<type>test-jar</type>
106107
</dependency>
107108
<dependency>
108109
<groupId>org.hsqldb</groupId>
109110
<artifactId>hsqldb</artifactId>
110111
<scope>test</scope>
111112
</dependency>
112-
<dependency>
113-
<groupId>org.slf4j</groupId>
114-
<artifactId>slf4j-simple</artifactId>
115-
<scope>provided</scope>
116-
</dependency>
117-
<dependency>
118-
<groupId>javassist</groupId>
119-
<artifactId>javassist</artifactId>
120-
<scope>provided</scope>
121-
</dependency>
122-
<dependency>
123-
<groupId>cglib</groupId>
124-
<artifactId>cglib-nodep</artifactId>
125-
<scope>provided</scope>
126-
</dependency>
127113
<dependency>
128114
<groupId>junit</groupId>
129115
<artifactId>junit</artifactId>
130116
</dependency>
131117
</dependencies>
132118

133119
<properties>
120+
<bundle.version.hibernate>[3,7)</bundle.version.hibernate>
134121
<bundle.export.package>!com.thoughtworks.xstream.hibernate.util,com.thoughtworks.xstream.hibernate.*;-noimport:=true</bundle.export.package>
135122
<jar.module.name>xstream.hibernate</jar.module.name>
136123
<surefire.argline>--add-opens java.base/java.lang=ALL-UNNAMED</surefire.argline>
124+
<bundle.import.package>
125+
org.hibernate.proxy;resolution:=optional;version="${bundle.version.hibernate}",
126+
org.hibernate.collection;resolution:=optional;version="${bundle.version.hibernate}",
127+
org.hibernate.collection.spi;resolution:=optional;version="${bundle.version.hibernate}",
128+
org.hibernate.collection.internal;resolution:=optional;version="${bundle.version.hibernate}",
129+
*
130+
</bundle.import.package>
137131
</properties>
138132
</project>

xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2012, 2013, 2014, 2018 XStream Committers.
2+
* Copyright (C) 2012, 2013, 2014, 2018, 2025 XStream Committers.
33
* All rights reserved.
44
*
55
* Created on 08.06.2012 by Joerg Schaible
@@ -17,35 +17,49 @@
1717
*/
1818
public class Hibernate {
1919
/** <code>PersistentBag</code> contains Hibernate's PersistenBag class type. */
20-
public final static Class<?> PersistentBag = loadHibernateType("org.hibernate.collection.internal.PersistentBag");
20+
public final static Class<?> PersistentBag = loadHibernateType("org.hibernate.collection.spi.PersistentBag");
2121
/** <code>PersistentList</code> contains Hibernate's PersistenList class type. */
22-
public final static Class<?> PersistentList = loadHibernateType("org.hibernate.collection.internal.PersistentList");
22+
public final static Class<?> PersistentList = loadHibernateType("org.hibernate.collection.spi.PersistentList");
2323
/** <code>PersistentMap</code> contains Hibernate's PersistenMap class type. */
24-
public final static Class<?> PersistentMap = loadHibernateType("org.hibernate.collection.internal.PersistentMap");
24+
public final static Class<?> PersistentMap = loadHibernateType("org.hibernate.collection.spi.PersistentMap");
2525
/** <code>PersistentSet</code> contains Hibernate's PersistenSet class type. */
26-
public final static Class<?> PersistentSet = loadHibernateType("org.hibernate.collection.internal.PersistentSet");
26+
public final static Class<?> PersistentSet = loadHibernateType("org.hibernate.collection.spi.PersistentSet");
2727
/** <code>PersistentSortedMap</code> contains Hibernate's PersistenSortedMap class type. */
28-
public final static Class<?> PersistentSortedMap = loadHibernateType("org.hibernate.collection.internal.PersistentSortedMap");
28+
public final static Class<?> PersistentSortedMap = loadHibernateType(
29+
"org.hibernate.collection.spi.PersistentSortedMap");
2930
/** <code>PersistentSortedSet</code> contains Hibernate's PersistenSortedSet class type. */
30-
public final static Class<?> PersistentSortedSet = loadHibernateType("org.hibernate.collection.internal.PersistentSortedSet");
31+
public final static Class<?> PersistentSortedSet = loadHibernateType(
32+
"org.hibernate.collection.spi.PersistentSortedSet");
3133
/** <code>EnversList</code> contains the ListProxy class type for Hibernate Envers. */
32-
public final static Class<?> EnversList = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.ListProxy");
34+
public final static Class<?> EnversList = loadHibernateEnversType(
35+
"org.hibernate.envers.entities.mapper.relation.lazy.proxy.ListProxy");
3336
/** <code>EnversMap</code> contains the MapProxy class type for Hibernate Envers. */
34-
public final static Class<?> EnversMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.MapProxy");
37+
public final static Class<?> EnversMap = loadHibernateEnversType(
38+
"org.hibernate.envers.entities.mapper.relation.lazy.proxy.MapProxy");
3539
/** <code>EnversSet</code> contains the SetProxy class type for Hibernate Envers. */
36-
public final static Class<?> EnversSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SetProxy");
40+
public final static Class<?> EnversSet = loadHibernateEnversType(
41+
"org.hibernate.envers.entities.mapper.relation.lazy.proxy.SetProxy");
3742
/** <code>EnversSortedMap</code> contains the SortedMapProxy class type for Hibernate Envers. */
38-
public final static Class<?> EnversSortedMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedMapProxy");
43+
public final static Class<?> EnversSortedMap = loadHibernateEnversType(
44+
"org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedMapProxy");
3945
/** <code>EnversSortedSet</code> contains the SortedSetProxy class type for Hibernate Envers. */
40-
public final static Class<?> EnversSortedSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedSetProxy");
46+
public final static Class<?> EnversSortedSet = loadHibernateEnversType(
47+
"org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedSetProxy");
4148

4249
private static Class<?> loadHibernateType(final String name) {
4350
Class<?> type = null;
4451
try {
4552
try {
46-
type = HibernateProxy.class.getClassLoader().loadClass(name);
47-
} catch (final ClassNotFoundException e) {
48-
type = HibernateProxy.class.getClassLoader().loadClass(name.replaceFirst("\\.internal\\.", "."));
53+
try {
54+
type = HibernateProxy.class.getClassLoader().loadClass(name);
55+
} catch (ClassNotFoundException e) {
56+
// test Hibernate version 5.x
57+
type = HibernateProxy.class.getClassLoader().loadClass(name.replaceFirst("\\.spi\\.",
58+
".internal."));
59+
}
60+
} catch (ClassNotFoundException e) {
61+
// test Hibernate version 3.x
62+
type = HibernateProxy.class.getClassLoader().loadClass(name.replaceFirst("\\.spi\\.", "."));
4963
}
5064
} catch (final ClassNotFoundException e) {
5165
// not available

xstream-hibernate/src/test/acceptance/hibernate/AbstractHibernateAcceptanceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2011, 2018 XStream Committers.
2+
* Copyright (C) 2011, 2018, 2025 XStream Committers.
33
* All rights reserved.
44
*
55
* The software in this package is published under the terms of the BSD
@@ -12,7 +12,6 @@
1212

1313
import org.hibernate.SessionFactory;
1414
import org.hibernate.cfg.Configuration;
15-
import org.hibernate.service.internal.BootstrapServiceRegistryImpl;
1615

1716
import com.thoughtworks.acceptance.AbstractAcceptanceTest;
1817
import com.thoughtworks.xstream.XStream;

xstream-hibernate/src/test/acceptance/hibernate/HibernateCollectionsTypeCompatibilityTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2011, 2012, 2018 XStream Committers.
2+
* Copyright (C) 2011, 2012, 2018, 2025 XStream Committers.
33
* All rights reserved.
44
*
55
* The software in this package is published under the terms of the BSD
@@ -29,39 +29,40 @@
2929
public class HibernateCollectionsTypeCompatibilityTest extends AbstractHibernateAcceptanceTest {
3030

3131
public void testPersistentBag() {
32-
assertXmlEquals(new ArrayList<Object>(), newHibernateCollection(Hibernate.PersistentBag, Collections
32+
assertXmlEquals(new ArrayList<>(), newHibernateCollection(Hibernate.PersistentBag, Collections
3333
.emptyList()));
3434
}
3535

3636
public void testPersistentList() {
37-
assertXmlEquals(new ArrayList<Object>(), newHibernateCollection(Hibernate.PersistentList, Collections
37+
assertXmlEquals(new ArrayList<>(), newHibernateCollection(Hibernate.PersistentList, Collections
3838
.emptyList()));
3939
}
4040

4141
public void testPersistentMap() {
42-
assertXmlEquals(new HashMap<Object, Object>(), newHibernateCollection(Hibernate.PersistentMap, Collections
42+
assertXmlEquals(new HashMap<>(), newHibernateCollection(Hibernate.PersistentMap, Collections
4343
.emptyMap()));
4444
}
4545

4646
public void testPersistentSet() {
47-
assertXmlEquals(new HashSet<Object>(), newHibernateCollection(Hibernate.PersistentSet, Collections.emptySet()));
47+
assertXmlEquals(new HashSet<>(), newHibernateCollection(Hibernate.PersistentSet, Collections.emptySet()));
4848
}
4949

5050
public void testPersistentSortedMap() {
51-
assertXmlEquals(new TreeMap<Object, Object>(), newHibernateCollection(Hibernate.PersistentSortedMap,
52-
new TreeMap<Object, Object>()));
51+
assertXmlEquals(new TreeMap<>(), newHibernateCollection(Hibernate.PersistentSortedMap,
52+
new TreeMap<>()));
5353
}
5454

5555
public void testPersistentSortedSet() {
56-
assertXmlEquals(new TreeSet<Object>(), newHibernateCollection(Hibernate.PersistentSortedSet,
57-
new TreeSet<Object>()));
56+
assertXmlEquals(new TreeSet<>(), newHibernateCollection(Hibernate.PersistentSortedSet,
57+
new TreeSet<>()));
5858
}
5959

6060
private Object newHibernateCollection(final Class<?> type, final Object secondArg) {
6161
Object instance = null;
6262
final Constructor<?>[] ctors = type.getConstructors();
6363
for (final Constructor<?> ctor : ctors) {
64-
if (ctor.getParameterTypes().length == 2) {
64+
if (ctor.getParameterTypes().length == 2
65+
&& ctor.getParameterTypes()[1].isAssignableFrom(secondArg.getClass())) {
6566
try {
6667
instance = ctor.newInstance(null, secondArg);
6768
} catch (final InstantiationException e) {

0 commit comments

Comments
 (0)