diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java b/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java index 60cf247d09..fc8f676e12 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -709,6 +709,7 @@ public abstract class AbstractEntityManagerFactoryBean implements } @Override + @Nullable public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { switch (method.getName()) { case "equals" -> { @@ -729,6 +730,10 @@ public abstract class AbstractEntityManagerFactoryBean implements return proxy; } } + case "getName" -> { + // Handle JPA 3.2 getName method locally. + return this.entityManagerFactoryBean.getPersistenceUnitName(); + } } try { diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index e5991b3913..5ebc6ac802 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -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"); * 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() "executeUpdate", // jakarta.persistence.Query.executeUpdate() "getSingleResult", // jakarta.persistence.Query.getSingleResult() + "getSingleResultOrNull", // jakarta.persistence.Query.getSingleResultOrNull() "getResultStream", // jakarta.persistence.Query.getResultStream() "getResultList", // jakarta.persistence.Query.getResultList() "list", // org.hibernate.query.Query.list()