Skip to content

Commit 5acee7b

Browse files
committed
Initial support for JPA 3.2
Includes proxy support for Query#getSingleResultOrNull() and EntityManagerFactory#getName() invocations. Closes gh-31157
1 parent 7c5bcbc commit 5acee7b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -709,6 +709,7 @@ public ManagedEntityManagerFactoryInvocationHandler(AbstractEntityManagerFactory
709709
}
710710

711711
@Override
712+
@Nullable
712713
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
713714
switch (method.getName()) {
714715
case "equals" -> {
@@ -729,6 +730,10 @@ else if (targetClass.isInstance(proxy)) {
729730
return proxy;
730731
}
731732
}
733+
case "getName" -> {
734+
// Handle JPA 3.2 getName method locally.
735+
return this.entityManagerFactoryBean.getPersistenceUnitName();
736+
}
732737
}
733738

734739
try {

Diff for: spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -85,6 +85,7 @@ public abstract class SharedEntityManagerCreator {
8585
"execute", // jakarta.persistence.StoredProcedureQuery.execute()
8686
"executeUpdate", // jakarta.persistence.Query.executeUpdate()
8787
"getSingleResult", // jakarta.persistence.Query.getSingleResult()
88+
"getSingleResultOrNull", // jakarta.persistence.Query.getSingleResultOrNull()
8889
"getResultStream", // jakarta.persistence.Query.getResultStream()
8990
"getResultList", // jakarta.persistence.Query.getResultList()
9091
"list", // org.hibernate.query.Query.list()

0 commit comments

Comments
 (0)