Initial support for JPA 3.2

Includes proxy support for Query#getSingleResultOrNull() and EntityManagerFactory#getName() invocations.

Closes gh-31157
This commit is contained in:
Juergen Hoeller
2024-02-28 17:35:37 +01:00
parent 7c5bcbcba4
commit 5acee7b22e
2 changed files with 8 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -709,6 +709,7 @@ public abstract class AbstractEntityManagerFactoryBean implements
} }
@Override @Override
@Nullable
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
switch (method.getName()) { switch (method.getName()) {
case "equals" -> { case "equals" -> {
@@ -729,6 +730,10 @@ public abstract class AbstractEntityManagerFactoryBean implements
return proxy; return proxy;
} }
} }
case "getName" -> {
// Handle JPA 3.2 getName method locally.
return this.entityManagerFactoryBean.getPersistenceUnitName();
}
} }
try { try {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -85,6 +85,7 @@ public abstract class SharedEntityManagerCreator {
"execute", // jakarta.persistence.StoredProcedureQuery.execute() "execute", // jakarta.persistence.StoredProcedureQuery.execute()
"executeUpdate", // jakarta.persistence.Query.executeUpdate() "executeUpdate", // jakarta.persistence.Query.executeUpdate()
"getSingleResult", // jakarta.persistence.Query.getSingleResult() "getSingleResult", // jakarta.persistence.Query.getSingleResult()
"getSingleResultOrNull", // jakarta.persistence.Query.getSingleResultOrNull()
"getResultStream", // jakarta.persistence.Query.getResultStream() "getResultStream", // jakarta.persistence.Query.getResultStream()
"getResultList", // jakarta.persistence.Query.getResultList() "getResultList", // jakarta.persistence.Query.getResultList()
"list", // org.hibernate.query.Query.list() "list", // org.hibernate.query.Query.list()