Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPENJPA-2668] fix for execution of a CriteriaQuery leaking into CriteriaQuery state #40

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openjpa-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-all</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-examples/image-gallery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-examples</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<groupId>org.apache.openjpa.openjpa-examples</groupId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-examples/openbooks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-examples</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<groupId>org.apache.openjpa.openjpa-examples</groupId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-examples</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-examples/simple/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-examples</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<groupId>org.apache.openjpa.openjpa-examples</groupId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-features/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-features</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-integration/daytrader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-integration</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-integration-daytrader</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-integration/examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-integration</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-integration-examples</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-integration/jmx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-integration</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-integration-jmx</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-integration</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-integration/slf4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-integration</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-integration-slf4j</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-integration/tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-integration</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-integration-tck</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-integration/validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-integration</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-integration-validation</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-jdbc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-jest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-jest</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-kernel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-kernel</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-lib</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-persistence-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-persistence-jdbc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.apache.openjpa.persistence.criteria;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import javax.persistence.EntityManager;
Expand All @@ -27,6 +29,7 @@
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.ParameterExpression;

import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.query.DomainObject;
Expand Down Expand Up @@ -646,5 +649,25 @@ void setParameters(Query q, Object...p) {
q.setParameter(p[i].toString(), p[i+1]);
}
}

public void testInCriteriaWithCollection() {

OpenJPAEntityManager em = emf.createEntityManager();
CriteriaBuilder builder = em.getCriteriaBuilder();

CriteriaQuery<Customer> criteria = builder.createQuery(Customer.class);
Root<Customer> root = criteria.from(Customer.class);
criteria.where(root.get("status").in(builder.parameter(Collection.class)));

TypedQuery<Customer> query = em.createQuery(criteria);
System.err.println(query);
for (ParameterExpression parameter : criteria.getParameters()) {
query.setParameter(parameter, Arrays.asList(1L, 2L));
}

assertEquals("SELECT * FROM Customer c WHERE c.status IN (:param)", criteria.toString());
query.getResultList();
assertEquals("SELECT * FROM Customer c WHERE c.status IN (:param)", criteria.toString());
}
}

2 changes: 1 addition & 1 deletion openjpa-persistence-locking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-persistence-locking</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-persistence</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,12 @@ public In(Expression<?> e) {
this.e = (ExpressionImpl<T>)e;
}

private Expressions.In<?> copy() {
In<?> in = new Expressions.In<>(this.e);
in._exps.addAll(this._exps);
return in;
}

@Override
public Expression<T> getExpression() {
return e;
Expand Down Expand Up @@ -1468,7 +1474,11 @@ public PredicateImpl not() {
}

@Override
org.apache.openjpa.kernel.exps.Expression toKernelExpression(
org.apache.openjpa.kernel.exps.Expression toKernelExpression(ExpressionFactory factory, CriteriaQueryImpl<?> q) {
return copy().toKernelExpression0(factory, q);
}

org.apache.openjpa.kernel.exps.Expression toKernelExpression0(
ExpressionFactory factory, CriteriaQueryImpl<?> q) {
org.apache.openjpa.kernel.exps.Expression inExpr = null;
if (_exps.size() == 1) {
Expand Down
2 changes: 1 addition & 1 deletion openjpa-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>apache-openjpa</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-slice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-slice</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-tools/openjpa-fetch-statistics-was/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-tools</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-fetch-statistics-was</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-tools/openjpa-fetch-statistics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-tools</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-fetch-statistics</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa-tools/openjpa-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-tools</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion openjpa-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
<!-- <relativePath>../pom.xml</relativePath>-->
</parent>

Expand Down
2 changes: 1 addition & 1 deletion openjpa-xmlstore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa-xmlstore</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openjpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
</parent>

<artifactId>openjpa</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<name>OpenJPA Parent POM</name>
<description>Apache OpenJPA implementation of JSR-338 JPA 2.1</description>

<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>

<properties>
<java.class.version>1.8</java.class.version>
Expand Down Expand Up @@ -160,7 +160,7 @@
<connection>scm:git:https://gitbox.apache.org/repos/asf/openjpa.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/openjpa.git</developerConnection>
<url>https://gitbox.apache.org/repos/asf/openjpa.git</url>
<tag>3.1.0</tag>
<tag>HEAD</tag>
</scm>

<modules>
Expand Down