aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Kraus2014-03-05 05:14:06 (EST)
committerGordon Yorke2014-03-05 11:40:22 (EST)
commite074badfb825c73c1d532f56d37381f43306d7fa (patch)
tree1e953228ea2ef42674c11535621abfdf4ddb69b1
parentcbe64ea2447fb6922e7ce85546d7a34b3bdce413 (diff)
downloadeclipselink.runtime-e074badfb825c73c1d532f56d37381f43306d7fa.zip
eclipselink.runtime-e074badfb825c73c1d532f56d37381f43306d7fa.tar.gz
eclipselink.runtime-e074badfb825c73c1d532f56d37381f43306d7fa.tar.bz2
Bug# 429232 - Instance of UnitOfWork is stored in ExpressionBuilder inside ConcurrentFixedCache. setSession(AbstractSession session) method in ExpressionBuilder will always store root session to avoid storing UnitOfWork. Signed-off-by: Tomas Kraus <tomas.kraus@oracle.com>
-rw-r--r--foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionBuilderTestSuite.java54
-rw-r--r--foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionTestSuite.java4
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/ExpressionBuilder.java4
3 files changed, 60 insertions, 2 deletions
diff --git a/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionBuilderTestSuite.java b/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionBuilderTestSuite.java
new file mode 100644
index 0000000..0f7ceca
--- /dev/null
+++ b/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionBuilderTestSuite.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Tomas Kraus - Initial API and implementation.
+ ******************************************************************************/
+package org.eclipse.persistence.testing.tests.expressions;
+
+import org.eclipse.persistence.expressions.ExpressionBuilder;
+import org.eclipse.persistence.internal.sessions.AbstractSession;
+import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
+import org.eclipse.persistence.sessions.UnitOfWork;
+import org.eclipse.persistence.testing.framework.TestCase;
+import org.eclipse.persistence.testing.framework.TestErrorException;
+
+/**
+ * Test ExpressionBuilder class and instance methods.
+ */
+public class ExpressionBuilderTestSuite extends TestCase {
+
+ public ExpressionBuilderTestSuite() {
+ super();
+ setName(getName());
+ setDescription("Test ExpressionBuilder class and instance methods");
+ }
+
+ public void setup() {
+ }
+
+ // Execute all tests in suite.
+ public void test() {
+ testUnitOfWorkInExpressionBuilder();
+ }
+
+ // Bug# 429232 - Instance of UnitOfWork is stored in ExpressionBuilder inside ConcurrentFixedCache
+ // Make sure that [ExpressionBuilder].setSession() will not store UnitOfWork inside builder even
+ // when UnitOfWork is passed as an argument.
+ public void testUnitOfWorkInExpressionBuilder() {
+ ExpressionBuilder builder = new ExpressionBuilder();
+ UnitOfWorkImpl uow = (UnitOfWorkImpl)getSession().acquireUnitOfWork();
+ builder.setSession(uow);
+ AbstractSession session = builder.getSession();
+ if (session instanceof UnitOfWork) {
+ throw new TestErrorException("Session stored in ExpressionBuilder shall not be UnitOfWork.");
+ }
+ }
+
+}
diff --git a/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionTestSuite.java b/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionTestSuite.java
index 7d8e19a..4ccdfb6 100644
--- a/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionTestSuite.java
+++ b/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -1710,6 +1710,8 @@ public class ExpressionTestSuite extends TestSuite {
addTest(new LowerCaseForCaseInsensitiveTest(LowerCaseForCaseInsensitiveTest.EqualsIgnoreCase));
addTest(new LowerCaseForCaseInsensitiveTest(LowerCaseForCaseInsensitiveTest.LikeIgnoreCase));
addTest(new LowerCaseForCaseInsensitiveTest(LowerCaseForCaseInsensitiveTest.ContainsSubstringIgnoringCase));
+ // ExpressionBuilder test suite
+ addTest(new ExpressionBuilderTestSuite());
}
//SRG test set is maintained by QA only, do NOT add any new tests into it.
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/ExpressionBuilder.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/ExpressionBuilder.java
index 5484f24..7050fae 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/ExpressionBuilder.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/ExpressionBuilder.java
@@ -24,6 +24,7 @@ import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.internal.expressions.*;
import org.eclipse.persistence.queries.DatabaseQuery;
import org.eclipse.persistence.queries.ReadQuery;
+import org.eclipse.persistence.sessions.UnitOfWork;
/**
* <P>
@@ -415,9 +416,10 @@ public class ExpressionBuilder extends ObjectExpression {
/**
* INTERNAL:
* Set the session in which we expect this expression to be translated.
+ * Stored session shall always be root session.
*/
public void setSession(AbstractSession session) {
- this.session = session;
+ this.session = session.getRootSession(null);
}
/**