Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Kraus2015-07-31 13:01:52 +0000
committerTomas Kraus2015-07-31 13:01:52 +0000
commit2f9c1fd08fb5600aebec9599c4d365a62c79175a (patch)
treece135a79fc76890976761d532b40c4608a0a630d
parent6e43db398374d750b178f1760536444c2cd9034e (diff)
downloadeclipselink.runtime-2.4.tar.gz
eclipselink.runtime-2.4.tar.xz
eclipselink.runtime-2.4.zip
Bug# 429232 - Instance of UnitOfWork is stored in ExpressionBuilder inside ConcurrentFixedCache.2.4
Signed-off-by: Tomas Kraus <tomas.kraus@oracle.com> Reviewed-by: Gordon Yorke
-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.java6
3 files changed, 61 insertions, 3 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 0000000000..e23f50b908
--- /dev/null
+++ b/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionBuilderTestSuite.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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 1d4fe11a0b..fce7895e88 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, 2015 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.
@@ -1708,6 +1708,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 bd3aa14378..f9c8875755 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015 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.
@@ -23,6 +23,7 @@ import org.eclipse.persistence.internal.sessions.AbstractRecord;
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.internal.expressions.*;
import org.eclipse.persistence.queries.DatabaseQuery;
+import org.eclipse.persistence.sessions.UnitOfWork;
/**
* <P>
@@ -410,9 +411,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);
}
/**

Back to the top