From 1b6f3f1f226d381f460aec4680e87bebb7521547 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 20 Jan 2010 15:39:17 +0000 Subject: [PATCH] Query call chaining works with shared EntityManager proxy outside of transaction as well (SPR-6726) --- .../springframework/orm/jpa/SharedEntityManagerCreator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index 5092ecbf3d..066e85e4e0 100644 --- a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 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. @@ -283,7 +283,8 @@ public abstract class SharedEntityManagerCreator { // Invoke method on actual Query object. try { - return method.invoke(this.target, args); + Object retVal = method.invoke(this.target, args); + return (retVal == this.target ? proxy : retVal); } catch (InvocationTargetException ex) { throw ex.getTargetException();