Skip to content

Commit 1954670

Browse files
committed
Drop JpaSystemException(PersistenceException) constructor to avoid ambiguity in HibernateJpaVendorAdapter
Hibernate 5.2's HibernateException extends PersistenceException, leading to a different constructor compiled into the bytecode, breaking compatibility with Hibernate 5.0 at runtime. Issue: SPR-13827
1 parent e4def2f commit 1954670

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.orm.jpa;
1818

19-
import java.lang.reflect.Method;
2019
import java.util.Map;
2120
import javax.persistence.EntityExistsException;
2221
import javax.persistence.EntityManager;
@@ -52,9 +51,7 @@
5251
import org.springframework.transaction.support.ResourceHolderSynchronization;
5352
import org.springframework.transaction.support.TransactionSynchronizationManager;
5453
import org.springframework.util.Assert;
55-
import org.springframework.util.ClassUtils;
5654
import org.springframework.util.CollectionUtils;
57-
import org.springframework.util.ReflectionUtils;
5855
import org.springframework.util.StringUtils;
5956

6057
/**
@@ -395,7 +392,7 @@ public static DataAccessException convertJpaAccessExceptionIfPossible(RuntimeExc
395392

396393
// If we have another kind of PersistenceException, throw it.
397394
if (ex instanceof PersistenceException) {
398-
return new JpaSystemException((PersistenceException) ex);
395+
return new JpaSystemException(ex);
399396
}
400397

401398
// If we get here, we have an exception that resulted from user code,

spring-orm/src/main/java/org/springframework/orm/jpa/JpaSystemException.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.orm.jpa;
1818

19-
import javax.persistence.PersistenceException;
20-
2119
import org.springframework.dao.UncategorizedDataAccessException;
2220

2321
/**
@@ -32,10 +30,6 @@
3230
@SuppressWarnings("serial")
3331
public class JpaSystemException extends UncategorizedDataAccessException {
3432

35-
public JpaSystemException(PersistenceException ex) {
36-
super(ex.getMessage(), ex);
37-
}
38-
3933
public JpaSystemException(RuntimeException ex) {
4034
super(ex.getMessage(), ex);
4135
}

0 commit comments

Comments
 (0)