From c3175eea3c3885286898170fae6b487b070f60b5 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Fri, 20 Mar 2009 19:47:26 +0000 Subject: [PATCH] OPENJPA-995: Refactor OpenJPA Criteria query implementation as 'dynamic query' extension. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@756730 13f79535-47bb-0310-9956-ffa450edef68 --- .../persistence/criteria/TestCriteria.java | 20 +- .../persistence/EntityManagerFactoryImpl.java | 10 +- .../persistence/EntityManagerImpl.java | 12 +- .../persistence/OpenJPAEntityManager.java | 8 + .../OpenJPAEntityManagerFactory.java | 9 +- .../query/AbstractDomainObject.java | 11 - .../persistence/query/AbstractPath.java | 8 +- .../openjpa/persistence/query/Aggregate.java | 30 + .../persistence/query/AliasContext.java | 2 - .../persistence/query/AllExpression.java | 4 - .../persistence/query/AndPredicate.java | 1 - .../persistence/query/AnyExpression.java | 3 - .../persistence/query/BetweenExpression.java | 3 - .../query/BinaryExpressionPredicate.java | 3 - .../query/BinaryOperatorExpression.java | 2 - .../persistence/query/CaseExpression.java | 299 +++++++++ .../persistence/query/CaseExpressionImpl.java | 4 - .../persistence/query/CountExpression.java | 2 - .../persistence/query/DistinctExpression.java | 2 - .../query/DividedByExpression.java | 2 - .../persistence/query/DomainObject.java | 123 ++++ .../persistence/query/ElseExpression.java | 2 - .../persistence/query/EqualExpression.java | 7 +- .../openjpa/persistence/query/Expression.java | 524 ++++++++++++++++ .../persistence/query/ExpressionImpl.java | 8 - .../persistence/query/FetchJoinObject.java | 26 + .../openjpa/persistence/query/FetchPath.java | 2 - .../query/GreaterEqualExpression.java | 7 +- .../query/GreaterThanExpression.java | 2 - .../persistence/query/InExpression.java | 21 +- .../persistence/query/IndexExpression.java | 2 - .../persistence/query/IsEmptyExpression.java | 21 +- .../persistence/query/IsNullExpression.java | 2 - .../openjpa/persistence/query/JoinPath.java | 1 - .../persistence/query/LengthExpression.java | 2 - .../query/LessEqualExpression.java | 2 - .../persistence/query/LessThanExpression.java | 2 - .../persistence/query/LikeExpression.java | 2 - .../persistence/query/LocateExpression.java | 2 - .../persistence/query/LogicalPredicate.java | 2 - .../persistence/query/LowerExpression.java | 2 - .../persistence/query/MaxExpression.java | 2 - .../persistence/query/MemberOfExpression.java | 2 - .../persistence/query/MinExpression.java | 2 - .../persistence/query/MinusExpression.java | 2 - .../persistence/query/NavigationPath.java | 1 - .../persistence/query/NewInstance.java | 3 - .../persistence/query/NotEqualExpression.java | 2 - .../query/OpenJPAQueryBuilder.java | 8 +- .../persistence/query/OrPredicate.java | 1 - .../openjpa/persistence/query/OrderBy.java | 35 ++ .../persistence/query/OrderByItem.java | 26 + .../persistence/query/OrderableItem.java | 2 - .../persistence/query/PathExpression.java | 117 ++++ .../persistence/query/PlusExpression.java | 2 - .../openjpa/persistence/query/Predicate.java | 53 ++ .../persistence/query/PredicateOperand.java | 588 ++++++++++++++++++ .../persistence/query/QueryBuilder.java | 57 ++ .../persistence/query/QueryBuilderImpl.java | 6 +- .../persistence/query/QueryDefinition.java | 556 +++++++++++++++++ .../query/QueryDefinitionImpl.java | 10 - .../persistence/query/QueryExpression.java | 2 - .../persistence/query/RangeExpression.java | 2 - .../openjpa/persistence/query/RootPath.java | 2 - .../openjpa/persistence/query/SelectItem.java | 45 ++ .../persistence/query/SizeExpression.java | 2 - .../persistence/query/SomeExpression.java | 2 - .../query/SquareRootExpression.java | 2 - .../query/SubStringExpression.java | 2 - .../openjpa/persistence/query/Subquery.java | 26 + .../persistence/query/SumExpression.java | 2 - .../persistence/query/TimesExpression.java | 2 - .../persistence/query/TrimExpression.java | 3 - .../openjpa/persistence/query/TrimSpec.java | 27 + .../persistence/query/TypeExpression.java | 2 - .../query/UnaryExpressionPredicate.java | 3 - .../query/UnaryMinusExpression.java | 2 - .../query/UnaryOperatorExpression.java | 3 - .../persistence/query/UpperExpression.java | 2 - .../persistence/query/VarArgsExpression.java | 4 - 80 files changed, 2625 insertions(+), 182 deletions(-) create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Aggregate.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpression.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DomainObject.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Expression.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchJoinObject.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderBy.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderByItem.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PathExpression.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Predicate.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PredicateOperand.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilder.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinition.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SelectItem.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Subquery.java create mode 100644 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimSpec.java diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java index ed695c9d2..28aa15ecd 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java @@ -21,16 +21,16 @@ package org.apache.openjpa.persistence.criteria; import java.util.List; -import javax.persistence.DomainObject; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Expression; import javax.persistence.Query; -import javax.persistence.QueryDefinition; -import javax.persistence.SelectItem; +import org.apache.openjpa.persistence.OpenJPAEntityManager; +import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory; +import org.apache.openjpa.persistence.query.DomainObject; +import org.apache.openjpa.persistence.query.Expression; import org.apache.openjpa.persistence.query.OpenJPAQueryBuilder; import org.apache.openjpa.persistence.query.QueryBuilderImpl; +import org.apache.openjpa.persistence.query.QueryDefinition; +import org.apache.openjpa.persistence.query.SelectItem; import org.apache.openjpa.persistence.test.SingleEMFTestCase; @@ -53,7 +53,7 @@ import org.apache.openjpa.persistence.test.SingleEMFTestCase; */ public class TestCriteria extends SingleEMFTestCase { protected OpenJPAQueryBuilder qb; - private static EntityManagerFactory emf = null; + private static OpenJPAEntityManagerFactory emf = null; protected StringComparison comparator = new StringComparison(); public void setUp() { @@ -82,7 +82,7 @@ public class TestCriteria extends SingleEMFTestCase { VideoStore.class); emf = super.emf; } - qb = (QueryBuilderImpl)emf.getQueryBuilder(); + qb = (QueryBuilderImpl)emf.getDynamicQueryBuilder(); emf.createEntityManager(); } @@ -540,14 +540,14 @@ public class TestCriteria extends SingleEMFTestCase { * their results. */ private void executeActually(String jpql, QueryDefinition q, Object...p) { - EntityManager em = emf.createEntityManager(); + OpenJPAEntityManager em = emf.createEntityManager(); List criteriaResult = null; List jpqlResult = null; Throwable criteriaError = null; Throwable jpqlError = null; try { - Query cq = em.createQuery(q); + Query cq = em.createDynamicQuery(q); setParameters(cq, p); criteriaResult = cq.getResultList(); } catch (Exception e) { diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java index e90fe05ba..33d130f91 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java @@ -30,6 +30,8 @@ import java.util.Set; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; +import javax.persistence.QueryBuilder; + import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.enhance.Reflection; import org.apache.openjpa.kernel.AutoDetach; @@ -350,8 +352,12 @@ public class EntityManagerFactoryImpl return getStoreCache(); } - public OpenJPAQueryBuilder getQueryBuilder() { - return new QueryBuilderImpl(this); + public QueryBuilder getQueryBuilder() { + return null; + } + + public OpenJPAQueryBuilder getDynamicQueryBuilder() { + return new QueryBuilderImpl(this); } public Set getSupportedProperties() { diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java index 0abf0d069..6d6ea034f 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java @@ -41,6 +41,7 @@ import javax.persistence.EntityManager; import javax.persistence.FlushModeType; import javax.persistence.LockModeType; import javax.persistence.Query; +import javax.persistence.QueryBuilder; import javax.persistence.QueryDefinition; import org.apache.commons.lang.StringUtils; @@ -1482,7 +1483,12 @@ public class EntityManagerImpl } public Query createQuery(QueryDefinition qdef) { - String jpql = getQueryBuilder().toJPQL(qdef); + return null; + } + + public OpenJPAQuery createDynamicQuery( + org.apache.openjpa.persistence.query.QueryDefinition qdef) { + String jpql = _emf.getDynamicQueryBuilder().toJPQL(qdef); return createQuery(jpql); } @@ -1501,8 +1507,8 @@ public class EntityManagerImpl return finalMap; } - public OpenJPAQueryBuilder getQueryBuilder() { - return new QueryBuilderImpl(_emf); + public QueryBuilder getQueryBuilder() { + return null; } public Set getSupportedProperties() { diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java index 9ca766bf4..6744f111c 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java @@ -31,6 +31,7 @@ import org.apache.openjpa.kernel.AutoDetach; import org.apache.openjpa.kernel.ConnectionRetainModes; import org.apache.openjpa.kernel.DetachState; import org.apache.openjpa.kernel.RestoreState; +import org.apache.openjpa.persistence.query.QueryDefinition; /** * Interface implemented by OpenJPA entity managers. @@ -660,6 +661,13 @@ public interface OpenJPAEntityManager * Create a new query in the given language. */ public OpenJPAQuery createQuery(String language, String query); + + /** + * Create an executable query from a dynamically defined query. + * + * @since 2.0.0 + */ + public OpenJPAQuery createDynamicQuery(QueryDefinition dynamic); /////////// // Locking diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java index 87a7b5e5a..0ecb90dee 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManagerFactory.java @@ -20,9 +20,11 @@ package org.apache.openjpa.persistence; import java.io.Serializable; import java.util.Map; -import java.util.Properties; + import javax.persistence.EntityManagerFactory; +import org.apache.openjpa.persistence.query.QueryBuilder; + /** * Interface implemented by OpenJPA entity manager factories. * @@ -123,4 +125,9 @@ public interface OpenJPAEntityManagerFactory * method pierces the published-API boundary, as does the SPI cast. */ public void removeTransactionListener(Object listener); + + /** + * Gets a builder for dynamic queries. + */ + public QueryBuilder getDynamicQueryBuilder(); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractDomainObject.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractDomainObject.java index b68d54a01..abae17660 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractDomainObject.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractDomainObject.java @@ -22,17 +22,6 @@ import java.util.Calendar; import java.util.Date; import java.util.List; -import javax.persistence.CaseExpression; -import javax.persistence.DomainObject; -import javax.persistence.Expression; -import javax.persistence.FetchJoinObject; -import javax.persistence.OrderByItem; -import javax.persistence.PathExpression; -import javax.persistence.Predicate; -import javax.persistence.QueryDefinition; -import javax.persistence.SelectItem; -import javax.persistence.Subquery; - /** * Domain Object is a path expression over which query is evaluated. * Domain object acts as a proxy for a QueryDefinition via delegation. diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractPath.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractPath.java index 51760374d..581f2937f 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractPath.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AbstractPath.java @@ -20,11 +20,6 @@ package org.apache.openjpa.persistence.query; import java.util.LinkedList; -import javax.persistence.Aggregate; -import javax.persistence.Expression; -import javax.persistence.PathExpression; -import javax.persistence.Predicate; - /** * An abstract path is formed by two parts : the first part is a parent path. * The second part can be an attribute or an operation (e.g. KEY() or VALUE()) @@ -49,7 +44,8 @@ abstract class AbstractPath extends ExpressionImpl implements protected final PathOperator _operator; protected final QueryDefinitionImpl _owner; - protected AbstractPath(QueryDefinitionImpl owner, AbstractPath parent, PathOperator op, Object part2) { + protected AbstractPath(QueryDefinitionImpl owner, AbstractPath parent, + PathOperator op, Object part2) { _owner = owner; _parent = parent; _part2 = part2; diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Aggregate.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Aggregate.java new file mode 100644 index 000000000..0b3c0da6f --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Aggregate.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.query; + +/** + * Type of the result of an aggregate operation + */ +public interface Aggregate extends Expression { + /** + * Specify that duplicates are to be removed before the aggregate operation + * is invoked. + */ + Expression distinct(); +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AliasContext.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AliasContext.java index 6d743ecda..7edac1d58 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AliasContext.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AliasContext.java @@ -22,8 +22,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Stack; -import javax.persistence.Expression; - import org.apache.openjpa.meta.MetaDataRepository; class AliasContext { diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AllExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AllExpression.java index 2bf922b94..85520824d 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AllExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AllExpression.java @@ -18,10 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.DomainObject; -import javax.persistence.QueryDefinition; -import javax.persistence.Subquery; - /** * Denotes All(SubQuery) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AndPredicate.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AndPredicate.java index 05d0dab51..0594339c8 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AndPredicate.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AndPredicate.java @@ -18,7 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Predicate; import static org.apache.openjpa.persistence.query.ConditionalOperator.*; /** diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AnyExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AnyExpression.java index 16dbb04ce..f2b97bf13 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AnyExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/AnyExpression.java @@ -18,9 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.QueryDefinition; -import javax.persistence.Subquery; - /** * Denotes ANY(SUbquery) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BetweenExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BetweenExpression.java index 75c85bbdd..2939e08f8 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BetweenExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BetweenExpression.java @@ -18,9 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - - /** * Denotes e1 BETWEEN(e2 AND e3) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java index aa5e10a8d..32268dc84 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java @@ -18,9 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; -import javax.persistence.Predicate; - /** * Binary predicate combines two expressions with an operator. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryOperatorExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryOperatorExpression.java index 4392ce576..5566d01c3 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryOperatorExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryOperatorExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * An expression resulting from a binary operation on two expressions. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpression.java new file mode 100644 index 000000000..5701dcf29 --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpression.java @@ -0,0 +1,299 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.query; + +import java.util.Calendar; +import java.util.Date; + +/** + * Interface for the construction of case expressions + */ +public interface CaseExpression { + /** + * Add a when predicate clause to a general case expression. The when + * predicate must be followed by the corresponding then case expression that + * specifies the result of the specific case. Clauses are evaluated in the + * order added. + * + * @param pred - + * corresponds to the evaluation condition for the specific case + * @return CaseExpression corresponding to the case with the added when + * clause + */ + CaseExpression when(Predicate pred); + + /** + * Add a when clause to a simple case expression. The when case expression + * must be followed by the corresponding then case expression that specifies + * the result of the specific case. Clauses are evaluated in the order added + * + * @param when - + * corresponds to the value against which the case operand of the + * simple case is tested + * @return CaseExpression corresponding to the case with the added clause + */ + CaseExpression when(Expression when); + + /** + * Add a when clause to a simple case expression. The when case expression + * must be followed by the corresponding then case expression that specifies + * the result of the specific case. Clauses are evaluated in the order added + * + * @param when - + * corresponds to the value against which the case operand of the + * simple case is tested + * @return CaseExpression corresponding to the case with the added clause + */ + CaseExpression when(Number when); + + /** + * Add a when clause to a simple case expression. The when case expression + * must be followed by the corresponding then case expression that specifies + * the result of the specific case. Clauses are evaluated in the order added + * + * @param when - + * corresponds to the value against which the + * case operand of the simple case is tested + * @return CaseExpression corresponding to the case with the added clause + */ + CaseExpression when(String when); + + /** + * Add a when clause to a simple case expression. The when case expression + * must be followed by the corresponding then case expression that specifies + * the result of the specific case. Clauses are evaluated in the order added + * + * @param when - + * corresponds to the value against which the case operand of the + * simple case is tested + * @return CaseExpression corresponding to the case with the added clause + */ + CaseExpression when(Date when); + + /** + * Add a when clause to a simple case expression. The when case expression + * must be followed by the corresponding then case expression that specifies + * the result of the specific case. Clauses are evaluated in the order added + * + * @param when - + * corresponds to the value against which the case operand of the + * simple case is tested + * @return CaseExpression corresponding to the case with the added clause + */ + CaseExpression when(Calendar when); + + /** + * Add a when clause to a simple case expression. The when case expression + * must be followed by the corresponding then case expression that specifies + * the result of the specific case. Clauses are evaluated in the order added + * + * @param when - + * corresponds to the value against which the case operand of the + * simple case is tested + * @return CaseExpression corresponding to the case with the added clause + */ + CaseExpression when(Class when); + + /** + * Add a when clause to a simple case expression. The when case expression + * must be followed by the corresponding then case expression that specifies + * the result of the specific case. Clauses are evaluated in the order added + * + * @param when - + * corresponds to the value against which the case operand of the + * simple case is tested + * @return CaseExpression corresponding to the case with the added clause + */ + CaseExpression when(Enum when); + + /** + * Add a then clause to a general or simple case expression. The then clause + * specifies the result corresponding to the immediately preceding when. + * Clauses are evaluated in the order added. + * + * @param then - + * corresponds to the result of the case expression if the when + * is satisfied + * @return CaseExpression corresponding to the case with the added then + * clause + */ + CaseExpression then(Expression then); + + /** + * Add a then clause to a general or simple case expression. The then clause + * specifies the result corresponding to the immediately preceding when. + * Clauses are evaluated in the order added. + * + * @param then - + * corresponds to the result of the case expression if the when + * is satisfied + * @return CaseExpression corresponding to the case with the added then + * clause + */ + CaseExpression then(Number then); + + /** + * Add a then clause to a general or simple case expression. The then clause + * specifies the result corresponding to the immediately preceding when. + * Clauses are evaluated in the order added. + * + * @param then - + * corresponds to the result of the case expression if the when + * is satisfied + * @return CaseExpression corresponding to the case with the added then + * clause + */ + CaseExpression then(String then); + + /** + * Add a then clause to a general or simple case expression. The then clause + * specifies the result corresponding to the immediately preceding when. + * Clauses are evaluated in the order added. + * + * @param then - + * corresponds to the result of the case expression if the when + * is satisfied + * @return CaseExpression corresponding to the case with the added then + * clause + */ + CaseExpression then(Date then); + + /** + * Add a then clause to a general or simple case expression. The then clause + * specifies the result corresponding to the immediately preceding when. + * Clauses are evaluated in the order added. + * + * @param then - + * corresponds to the result of the case expression if the when + * is satisfied + * @return CaseExpression corresponding to the case with the added then + * clause + */ + CaseExpression then(Calendar then); + + /** + * Add a then clause to a general or simple case expression. The then clause + * specifies the result corresponding to the immediately preceding when. + * Clauses are evaluated in the order added. + * + * @param then - + * corresponds to the result of the case expression if the when + * is satisfied + * @return CaseExpression corresponding to the case with the added then + * clause + */ + CaseExpression then(Class then); + + /** + * Add a then clause to a general or simple case expression. The then clause + * specifies the result corresponding to the immediately preceding when. + * Clauses are evaluated in the order added. + * + * @param then - + * corresponds to the result of the case expression if the when + * is satisfied + * @return CaseExpression corresponding to the case with the added then + * clause + */ + CaseExpression then(Enum then); + + /** + * Add else to a case expression. A case expression must have an else + * clause. + * + * @param arg - + * corresponds to the result of the case expression if the when + * condition is not satisfied + * @return Expression corresponding to the case expression with the added + * clause + */ + Expression elseCase(Expression arg); + + /** + * Add else to a case expression. A case expression must have an else + * clause. + * + * @param arg - + * corresponds to the result of the case expression if the when + * condition is not satisfied + * @return Expression corresponding to the case expression with the added + * clause + */ + Expression elseCase(String arg); + + /** + * Add else to a case expression. A case expression must have an else + * clause. + * + * @param arg - + * corresponds to the result of the case expression if the when + * condition is not satisfied + * @return Expression corresponding to the case expression with the added + * clause + */ + Expression elseCase(Number arg); + + /** + * Add else to a case expression. A case expression must have an else + * clause. + * + * @param arg - + * corresponds to the result of the case expression if the when + * condition is not satisfied + * @return Expression corresponding to the case expression with the added + * clause + */ + Expression elseCase(Date arg); + + /** + * Add else to a case expression. A case expression must have an else + * clause. + * + * @param arg - + * corresponds to the result of the case expression if the when + * condition is not satisfied + * @return Expression corresponding to the case expression with the added + * clause + */ + Expression elseCase(Calendar arg); + + /** + * Add else to a case expression. A case expression must have an else + * clause. + * + * @param arg - + * corresponds to the result of the case expression if the when + * condition is not satisfied + * @return Expression corresponding to the case expression with the added + * clause + */ + Expression elseCase(Class arg); + + /** + * Add else to a case expression. A case expression must have an else + * clause. + * + * @param arg - + * corresponds to the result of the case expression if the when + * condition is not satisfied + * @return Expression corresponding to the case expression with the added + * clause + */ + Expression elseCase(Enum arg); +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpressionImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpressionImpl.java index fae3fa2af..f4fcf3b36 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpressionImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CaseExpressionImpl.java @@ -22,10 +22,6 @@ import java.util.Calendar; import java.util.Date; import java.util.LinkedList; -import javax.persistence.CaseExpression; -import javax.persistence.Expression; -import javax.persistence.Predicate; - public class CaseExpressionImpl implements CaseExpression, Visitable { private LinkedList _whens = new LinkedList(); private final Object _caseOperand; diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CountExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CountExpression.java index d5dd6f3e4..d7c1e7ae9 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CountExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/CountExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes COUNT(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DistinctExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DistinctExpression.java index 870dd8de0..930af197c 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DistinctExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DistinctExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes DISTINCT(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DividedByExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DividedByExpression.java index fdb14c885..c94b5987d 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DividedByExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DividedByExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1/e2 Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DomainObject.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DomainObject.java new file mode 100644 index 000000000..4f0224742 --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/DomainObject.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.query; + +/** + * Domain objects define the domain over which a query operates. A domain object + * plays a role analogous to that of a Java Persistence query language + * identification variable. + */ +public interface DomainObject extends PathExpression, QueryDefinition { + /** + * Extend the query domain by joining with a class that can be navigated to + * or that is embedded in the class corresponding to the domain object on + * which the method is invoked. This method is permitted to be invoked only + * when defining the domain of the query. It must not be invoked within the + * context of the select, where, groupBy, or having operations. The domain + * object must correspond to a class that contains the referenced attribute. + * The query definition is modified to include the newly joined domain + * object. + * + * @param attribute - + * name of the attribute that references the target of the join + * @return the new DomainObject that is added for the target of the join + */ + DomainObject join(String attribute); + + /** + * Extend the query domain by left outer joining with a class that can be + * navigated to or that is embedded in the class corresponding to the domain + * object on which the method is invoked. This method is permitted to be + * invoked only when defining the domain of the query. It must not be + * invoked within the context of the select, where, groupBy, or having + * operations. The domain object must correspond to a class that contains + * the referenced attribute. The query definition is modified to include the + * newly joined domain object. + * + * @param attribute - + * name of the attribute that references the target of the join + * @return the new DomainObject that is added for the target of the join + */ + DomainObject leftJoin(String attribute); + + /** + * Specify that the association or element collection that is referenced by + * the attribute be eagerly fetched through use of an inner join. The domain + * object must correspond to a class that contains the referenced attribute. + * The query is modified to include the joined domain object. + * + * @param attribute - + * name of the attribute that references the target of the join + * @return the FetchJoinObject that is added for the target of the join + */ + FetchJoinObject joinFetch(String attribute); + + /** + * Specify that the association or element collection that is referenced by + * the attribute be eagerly fetched through use of a left outer join. The + * domain object must correspond to a class that contains the referenced + * attribute. The query is modified to include the joined domain object. + * + * @param attribute - + * name of the attribute that references the target of the join + * @return the FetchJoinObject that is added for the target of the join + */ + FetchJoinObject leftJoinFetch(String attribute); + + /** + * Return a path expression corresponding to the value of a map-valued + * association or element collection. This method is only permitted to be + * invoked upon a domain object that corresponds to a map-valued association + * or element collection. + * + * @return PathExpression corresponding to the map value + */ + PathExpression value(); + + /** + * Return a path expression corresponding to the key of a map-valued + * association or element collection. This method is only permitted to be + * invoked upon a domain object that corresponds to a map-valued association + * or element collection. + * + * @return PathExpression corresponding to the map key + */ + PathExpression key(); + + /** + * Return a select item corresponding to the map entry of a map-valued + * association or element collection. This method is only permitted to be + * invoked upon a domain object that corresponds to a map-valued association + * or element collection. + * + * @return SelectItem corresponding to the map entry + */ + SelectItem entry(); + + /** + * Return an expression that corresponds to the index. of the domain object + * in the referenced association or element collection. This method is only + * permitted to be invoked upon a domain object that corresponds to a + * multi-valued association or element collection for which an order column + * has been defined. + * + * @return Expression denoting the index + */ + Expression index(); +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ElseExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ElseExpression.java index 19523375c..5b4aee950 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ElseExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ElseExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Else clause in a Case Statement. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/EqualExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/EqualExpression.java index 9d80c4b1f..c3a46fa3a 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/EqualExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/EqualExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1 = e2 Expression. * @@ -28,7 +26,10 @@ import javax.persistence.Expression; */ public class EqualExpression extends BinaryExpressionPredicate { public EqualExpression(Expression op1, Expression op2) { - super(op1, BinaryConditionalOperator.EQUAL, BinaryConditionalOperator.EQUAL_NOT, op2); + super(op1, + BinaryConditionalOperator.EQUAL, + BinaryConditionalOperator.EQUAL_NOT, + op2); } } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Expression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Expression.java new file mode 100644 index 000000000..9eec41088 --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Expression.java @@ -0,0 +1,524 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.query; + +/** + * Instances of this interface can be used either as select list items or as + * predicate operands. + */ +public interface Expression extends SelectItem, PredicateOperand { + /* + * Conditional predicates over expression items + */ + /** + * Create a predicate for testing whether the expression is a member of the + * association or element collection denoted by the path expression. The + * argument must correspond to a collection-valued association or element + * collection of like type. + * + * @param arg - + * a path expression that specifies a collection-valued + * association or an element collection + * @return conditional predicate + */ + Predicate member(PathExpression arg); + + /** + * Create a predicate for testing whether the value of the expression is + * null. + * + * @return conditional predicate + */ + Predicate isNull(); + + /** + * Create a predicate for testing whether the expression value is a member + * of the argument list. + * + * @param strings + * @return conditional predicate + */ + Predicate in(String... strings); + + /** + * Create a predicate for testing whether the expression value is a member + * of the argument list. + * + * @param nums + * @return conditional predicate + */ + Predicate in(Number... nums); + + /** + * Create a predicate for testing whether the expression value is a member + * of the argument list. + * + * @param enums + * @return conditional predicate + */ + Predicate in(Enum... enums); + + /** + * Create a predicate for testing whether the expression value is a member + * of the argument list. + * + * @param classes + * @return conditional predicate + */ + Predicate in(Class... classes); + + /** + * Create a predicate for testing whether the expression value is a member + * of the argument list. + * + * @param params + * @return conditional predicate + */ + Predicate in(Expression... params); + + /** + * Create a predicate for testing whether the expression value is a member + * of a subquery result. + * + * @param subquery + * @return conditional predicate + */ + Predicate in(Subquery subquery); + + /* + * Operations on strings + */ + /** + * String length This method must be invoked on an expression corresponding + * to a string. + * + * @return expression denoting the length of the string. + */ + Expression length(); + + /** + * Concatenate a string with other string(s). This method must be invoked on + * an expression corresponding to a string. + * + * @param str - + * string(s) + * @return expression denoting the concatenation of the strings, starting + * with the string corresponding to the expression on which the + * method was invoked. + */ + Expression concat(String... str); + + /** + * Concatenate a string with other string(s). This method must be invoked on + * an expression corresponding to a string. + * + * @param str - + * expression(s) corresponding to string(s) + * @return expression denoting the concatenation of the strings, starting + * with the string corresponding to the expression on which the + * method was invoked. + */ + Expression concat(Expression... str); + + /** + * Extract a substring starting at specified position through to the end of + * the string. This method must be invoked on an expression corresponding to + * a string. + * + * @param start - + * start position (1 indicates first position) + * @return expression denoting the extracted substring + */ + Expression substring(int start); + + /** + * Extract a substring starting at specified position through to the end of + * the string. This method must be invoked on an expression corresponding to + * a string. + * + * @param start - + * expression denoting start position (1 indicates first + * position) + * @return expression denoting the extracted substring + */ + Expression substring(Expression start); + + /** + * Extract a substring. This method must be invoked on an expression + * corresponding to a string. + * + * @param start - + * start position (1 indicates first position) + * @param len - + * length of the substring to be returned + * @return expression denoting the extracted substring + */ + Expression substring(int start, int len); + + /** + * Extract a substring. This method must be invoked on an expression + * corresponding to a string. + * + * @param start - + * start position (1 indicates first position) + * @param len - + * expression denoting length of the substring to return + * @return expression denoting the extracted substring + */ + Expression substring(int start, Expression len); + + /** + * Extract a substring. This method must be invoked on an expression + * corresponding to a string. + * + * @param start - + * expression denoting start position (1 indicates first + * position) + * @param len - + * length of the substring to return + * @return expression denoting the extracted substring + */ + Expression substring(Expression start, int len); + + /** + * Extract a substring. This method must be invoked on an expression + * corresponding to a string. + * + * @param start - + * expression denoting start position (1 indicates first + * position) + * @param len - + * expression denoting length of the substring to return + * @return expression denoting the extracted substring + */ + Expression substring(Expression start, Expression len); + + /** + * Convert string to lowercase. This method must be invoked on an expression + * corresponding to a string. + * + * @return expression denoting the string in lowercase + */ + Expression lower(); + + /** + * Convert string to uppercase. This method must be invoked on an expression + * corresponding to a string. + * + * @return expression denoting the string in uppercase + */ + Expression upper(); + + /** + * Trim leading and trailing blanks. This method must be invoked on an + * expression corresponding to a string. + * + * @return expression denoting trimmed string + */ + Expression trim(); + + /** + * Trim leading, trailing blanks (or both) as specified by trim spec. This + * method must be invoked on an expression corresponding to a string. + * + * @param spec - + * trim specification + * @return expression denoting trimmed string + */ + Expression trim(TrimSpec spec); + + /** + * Trim leading and trailing occurrences of character from the string. This + * method must be invoked on an expression corresponding to a string. + * + * @param c - + * character to be trimmed + * @return expression denoting trimmed string + */ + Expression trim(char c); + + /** + * Trim occurrences of the character from leading or trailing (or both) + * positions of the string, as specified by trim spec. This method must be + * invoked on an expression corresponding to a string. + * + * @param c - + * character to be trimmed + * @param spec - + * trim specification + * @return expression denoting trimmed string + */ + Expression trim(char c, TrimSpec spec); + + /** + * Trim leading and trailing occurrences of character specified by the + * expression argument from the string. This method must be invoked on an + * expression corresponding to a string. + * + * @param expr - + * expression corresponding to the character to be trimmed + * @return expression denoting trimmed string + */ + Expression trim(Expression expr); + + /** + * Trim occurrences of the character specified by the expression argument + * from leading or trailing (or both) positions of the string, as specified + * by trim spec. This method must be invoked on an expression corresponding + * to a string. + * + * @param expr - + * expression corresponding to the character to be trimmed + * @param spec - + * trim specification + * @return expression denoting trimmed string + */ + Expression trim(Expression expr, TrimSpec spec); + + /** + * Locate a string contained within the string corresponding to the + * expression on which the method was invoked. The search is started at + * position 1 (first string position). This method must be invoked on an + * expression corresponding to a string. + * + * @param str - + * string to be located + * @return expression denoting the first position at which the string was + * found or expression denoting 0 if the string was not found + */ + Expression locate(String str); + + /** + * Locate a string contained within the string corresponding to the + * expression on which the method was invoked. The search is started at + * position 1 (first string position). This method must be invoked on an + * expression corresponding to a string. + * + * @param str - + * expression corresponding to the string to be located + * @return expression denoting the first position at which the string was + * found or expression denoting 0 if the string was not found + */ + Expression locate(Expression str); + + /** + * Locate a string contained within the string corresponding to the + * expression on which the method was invoked, starting at a specified + * search position. This method must be invoked on an expression + * corresponding to a string. + * + * @param str - + * string to be located + * @param position - + * position at which to start the search + * @return expression denoting the first position at which the string was + * found or expression denoting 0 if the string was not found + */ + Expression locate(String str, int position); + + /** + * Locate a string contained within the string corresponding to the + * expression on which the method was invoked, starting at a specified + * search position. This method must be invoked on an expression + * corresponding to a string. + * + * @param str - + * string to be located + * @param position - + * expression corresponding to position at which to start the + * search + * @return expression denoting the first position at which the string was + * found or expression denoting 0 if the string was not found + */ + Expression locate(String str, Expression position); + + /** + * Locate a string contained within the string corresponding to the + * expression on which the method was invoked, starting at a specified + * search position. This method must be invoked on an expression + * corresponding to a string. + * + * @param str - + * expression corresponding to the string to be located + * @param position - + * position at which to start the search + * @return expression denoting the first position at which the string was + * found or expression denoting 0 if the string was not found + */ + Expression locate(Expression str, int position); + + /** + * Locate a string contained within the string corresponding to the + * expression on which the method was invoked, starting at a specified + * search position. This method must be invoked on an expression + * corresponding to a string. + * + * @param str - + * expression corresponding to the string to be located + * @param position - + * expression corresponding to position at which to start the + * search + * @return expression denoting the first position at which the string was + * found or expression denoting 0 if the string was not found + */ + Expression locate(Expression str, Expression position); + + /* + * Arithmetic operations + */ + /** + * Addition. This method must be invoked on an expression corresponding to a + * number. + * + * @param num - + * number to be added + * @return expression denoting the sum + */ + Expression plus(Number num); + + /** + * Addition. This method must be invoked on an expression corresponding to a + * number. + * + * @param expr - + * expression corresponding to number to be added + * @return expression denoting the sum + */ + Expression plus(Expression expr); + + /** + * Unary minus. This method must be invoked on an expression corresponding + * to a number. + * + * @return expression denoting the unary minus of the expression + */ + Expression minus(); + + /** + * Subtraction. This method must be invoked on an expression corresponding + * to a number. + * + * @param num - + * subtrahend + * @return expression denoting the result of subtracting the argument from + * the number corresponding to the expression on which the method + * was invoked. + */ + Expression minus(Number num); + + /** + * Subtraction. This method must be invoked on an expression corresponding + * to a number. + * + * @param expr - + * expression corresponding to subtrahend + * @return expression denoting the result of subtracting the number denoted + * by the argument from the number corresponding to the expression + * on which the method was invoked. + */ + Expression minus(Expression expr); + + /** + * Division. This method must be invoked on an expression corresponding to a + * number. + * + * @param num - + * divisor + * @return expression denoting the result of dividing the number + * corresponding to the expression on which the method was invoked + * by the argument + */ + Expression dividedBy(Number num); + + /** + * Division. This method must be invoked on an expression corresponding to a + * number. + * + * @param expr - + * expression corresponding to the divisor + * @return expression denoting the result of dividing the number + * corresponding to the expression on which the method was invoked + * by the number denoted by the argument + */ + Expression dividedBy(Expression expr); + + /** + * Multiplication. This method must be invoked on an expression + * corresponding to a number. + * + * @param num - + * multiplier + * @return expression denoting the result of multiplying the argument with + * the number corresponding to the expression on which the method + * was invoked. + */ + Expression times(Number num); + + /** + * Multiplication. This method must be invoked on an expression + * corresponding to a number. + * + * @param expr - + * expression corresponding to the multiplier + * @return expression denoting the result of multiplying the number denoted + * by the argument with the number corresponding to the expression + * on which the method was invoked. + */ + Expression times(Expression expr); + + /** + * Absolute value. This method must be invoked on an expression + * corresponding to a number. + * + * @return expression corresponding to the absolute value + */ + Expression abs(); + + /** + * Square root. This method must be invoked on an expression corresponding + * to a number. + * + * @return expression corresponding to the square root + */ + Expression sqrt(); + + /** + * Modulo operation. This must be invoked on an expression corresponding to + * an integer value + * + * @param num - + * integer divisor + * @return expression corresponding to the integer remainder of the division + * of the integer corresponding to the expression on which the + * method was invoked by the argument. + */ + Expression mod(int num); + + /** + * Modulo operation. This must be invoked on an expression corresponding to + * an integer value + * + * @param expr - + * expression corresponding to integer divisor + * @return expression corresponding to the integer remainder of the division + * of the integer corresponding to the expression on which the + * method was invoked by the argument. + */ + Expression mod(Expression expr); +} \ No newline at end of file diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ExpressionImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ExpressionImpl.java index cc1929199..247d44ef9 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ExpressionImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/ExpressionImpl.java @@ -22,14 +22,6 @@ import java.io.Serializable; import java.util.Calendar; import java.util.Date; -import javax.persistence.Expression; -import javax.persistence.OrderByItem; -import javax.persistence.PathExpression; -import javax.persistence.Predicate; -import javax.persistence.PredicateOperand; -import javax.persistence.Subquery; -import javax.persistence.TrimSpec; - /** * An abstract expression acts as a factory for concrete unary or binary * expressions such as ABS() or PLUS(). diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchJoinObject.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchJoinObject.java new file mode 100644 index 000000000..e8a9e4116 --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchJoinObject.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * Interface used for the result of a fetch join. + */ +public interface FetchJoinObject { +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchPath.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchPath.java index ab55f79ed..96d9b80ba 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchPath.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/FetchPath.java @@ -20,8 +20,6 @@ package org.apache.openjpa.persistence.query; import static org.apache.openjpa.persistence.query.PathOperator.NAVIGATION; -import javax.persistence.FetchJoinObject; - /** * Denotes a path used in fetch join. Simply wraps a Navigation Path. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterEqualExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterEqualExpression.java index f7c483ab0..29238ebf5 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterEqualExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterEqualExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1 >= e2 Expression. * @@ -28,7 +26,10 @@ import javax.persistence.Expression; */ public class GreaterEqualExpression extends BinaryExpressionPredicate { public GreaterEqualExpression(Expression op1, Expression op2) { - super(op1, BinaryConditionalOperator.GREATEREQUAL, BinaryConditionalOperator.LESS, op2); + super(op1, + BinaryConditionalOperator.GREATEREQUAL, + BinaryConditionalOperator.LESS, + op2); } } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterThanExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterThanExpression.java index 67b9feb2e..b78fa83e5 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterThanExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/GreaterThanExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1 > e2 Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/InExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/InExpression.java index faf067635..4ab73e802 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/InExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/InExpression.java @@ -1,8 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; -import javax.persistence.Subquery; - /** * Denotes e1 IN (e2) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IndexExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IndexExpression.java index 6865d9bc9..2d6b23896 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IndexExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IndexExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes INDEX(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsEmptyExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsEmptyExpression.java index a3cbb00d0..a8d0cc1e0 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsEmptyExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsEmptyExpression.java @@ -1,8 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - - public class IsEmptyExpression extends UnaryExpressionPredicate { public IsEmptyExpression(Expression op) { super(op, UnaryConditionalOperator.ISEMPTY, diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsNullExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsNullExpression.java index 23813e7a2..ff31d5dec 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsNullExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/IsNullExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e IS NULL Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/JoinPath.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/JoinPath.java index 23d7a5cce..7f4b38f34 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/JoinPath.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/JoinPath.java @@ -18,7 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.DomainObject; import static org.apache.openjpa.persistence.query.PathOperator.NAVIGATION; /** diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LengthExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LengthExpression.java index c1d973f7e..ef00dea94 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LengthExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LengthExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes LENGTH(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessEqualExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessEqualExpression.java index d42aa5fc3..ab0f653b4 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessEqualExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessEqualExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1 <= e2 Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessThanExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessThanExpression.java index 25c570791..78e3328f2 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessThanExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LessThanExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1 < e2 Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LikeExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LikeExpression.java index 8b605338a..02d2f88d7 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LikeExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LikeExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1 LIKE e2 Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LocateExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LocateExpression.java index 019b5de40..ce0c6760c 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LocateExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LocateExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes LOCATE(e1, e2, n) Expression. * e1 : string to be located diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LogicalPredicate.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LogicalPredicate.java index fede17276..62bd1c373 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LogicalPredicate.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LogicalPredicate.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Predicate; - /** * Logical Predicate combines two predicates with a logical operator. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LowerExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LowerExpression.java index 790059aae..8a108296a 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LowerExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/LowerExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes LOWER(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MaxExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MaxExpression.java index 883c00704..1698c272c 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MaxExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MaxExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes MAX(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MemberOfExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MemberOfExpression.java index 6a2e75645..61d37b930 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MemberOfExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MemberOfExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes e1 MEMBER OF e2 Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinExpression.java index f34b6f473..f4ead528f 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes MIN(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinusExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinusExpression.java index def1e822f..dca169155 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinusExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/MinusExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes (e1 - e2) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NavigationPath.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NavigationPath.java index 3c03a5dea..1b66ae824 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NavigationPath.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NavigationPath.java @@ -18,7 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.PathExpression; import static org.apache.openjpa.persistence.query.PathOperator.NAVIGATION; /** * Represents a path resulted by navigation. diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NewInstance.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NewInstance.java index 6486cb1d8..f78a9d23e 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NewInstance.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NewInstance.java @@ -21,9 +21,6 @@ package org.apache.openjpa.persistence.query; import java.util.Arrays; import java.util.List; -import javax.persistence.OrderByItem; -import javax.persistence.SelectItem; - /** * Denotes NEW fully.qualified.class.name(arg1, arg2,...) * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NotEqualExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NotEqualExpression.java index 00f5ec97d..b54d1cc68 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NotEqualExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/NotEqualExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes (e1 != e2) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OpenJPAQueryBuilder.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OpenJPAQueryBuilder.java index 69ebdbe6e..e834ebb9f 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OpenJPAQueryBuilder.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OpenJPAQueryBuilder.java @@ -18,18 +18,16 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Query; -import javax.persistence.QueryBuilder; -import javax.persistence.QueryDefinition; +import org.apache.openjpa.kernel.Query; /** - * An extension of standard JPA Specification interface to add equivalence of - * QueryDefinition and Query and JPQL String. + * Builds dynamic query * * @author Pinaki Poddar * */ public interface OpenJPAQueryBuilder extends QueryBuilder { + /** * Create a QueryDefinition from the given JPQL String. */ diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrPredicate.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrPredicate.java index 5b4ff3790..996a45727 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrPredicate.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrPredicate.java @@ -18,7 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Predicate; import static org.apache.openjpa.persistence.query.ConditionalOperator.*; /** diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderBy.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderBy.java new file mode 100644 index 000000000..89ad4716e --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderBy.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @version $Rev: 721048 $ $Date: 2008-11-26 18:23:43 -0600 (Wed, 26 Nov 2008) $ + */ +@Target({ElementType.METHOD, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface OrderBy { + String value() default ""; +} + diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderByItem.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderByItem.java new file mode 100644 index 000000000..609c5a56e --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderByItem.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * Instances of this interface can be used as orderBy arguments. + */ +public interface OrderByItem { +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderableItem.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderableItem.java index fe752b000..4bc24bbbd 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderableItem.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/OrderableItem.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.OrderByItem; - /** * Denotes an item of ORDER BY clause. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PathExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PathExpression.java new file mode 100644 index 000000000..3703a25f6 --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PathExpression.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * Interface for operations over objects reached via paths + */ +public interface PathExpression extends Expression { + /** + * Return a path expression corresponding to the referenced attribute. It is + * not permitted to invoke this method on a path expression that corresponds + * to a multi-valued association or element collection. The path expression + * on which this method is invoked must correspond to a class containing the + * referenced attribute. + * + * @param attributeName - + * name of the referenced attribute + * @return path expression + */ + PathExpression get(String attributeName); + + /** + * Return an expression that corresponds to the type of the entity. This + * method can only be invoked on a path expression corresponding to an + * entity. It is not permitted to invoke this method on a path expression + * that corresponds to a multi-valued association. + * + * @return expression denoting the entity's type + */ + Expression type(); + + /** + * Return an expression that corresponds to the number of elements + * association or element collection corresponding to the path expression. + * This method can only be invoked on a path expression that corresponds to + * a multi-valued association or to an element collection. + * + * @return expression denoting the size + */ + Expression size(); + + /** + * Add a restriction that the path expression must correspond to an + * association or element collection that is empty (has no elements). This + * method can only be invoked on a path expression that corresponds to a + * multi-valued association or to an element collection. + * + * @return predicate corresponding to the restriction + */ + Predicate isEmpty(); + + /** + * Specify that the avg operation is to be applied. The path expression must + * correspond to an attribute of a numeric type. It is not permitted to + * invoke this method on a path expression that corresponds to a + * multi-valued association or element collection. + * + * @return the resulting aggregate + */ + Aggregate avg(); + + /** + * Specify that the max operation is to be applied. The path expression must + * correspond to an attribute of an orderable type. It is not permitted to + * invoke this method on a path expression that corresponds to a + * multi-valued association or element collection. + * + * @return the resulting aggregate + */ + Aggregate max(); + + /** + * Specify that the min operation is to be applied. The path expression must + * correspond to an attribute of an orderable type. It is not permitted to + * invoke this method on a path expression that corresponds to a + * multi-valued association or element collection. + * + * @return the resulting aggregate + */ + Aggregate min(); + + /** + * Specify that the count operation is to be applied. It is not permitted to + * invoke this method on a path expression that corresponds to a + * multi-valued association or element collection. + * + * @return the resulting aggregate + */ + Aggregate count(); + + /** + * Specify that the sum operation is to be applied. The path expression must + * correspond to an attribute of a numeric type. It is not permitted to + * invoke this method on a path expression that corresponds to a + * multi-valued association or element collection. + * + * @return the resulting aggregate + */ + Aggregate sum(); +} \ No newline at end of file diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PlusExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PlusExpression.java index c8921cbc8..ae36656c7 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PlusExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PlusExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes (e1 + e2) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Predicate.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Predicate.java new file mode 100644 index 000000000..698b35b0d --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Predicate.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * Interface used to define compound predicates. + */ +public interface Predicate { + /** + * Creates an AND of the predicate with the argument. + * + * @param predicate - + * A simple or compound predicate + * @return the predicate that is the AND of the original simple or compound + * predicate and the argument. + */ + Predicate and(Predicate predicate); + + /** + * Creates an OR of the predicate with the argument. + * + * @param predicate - + * A simple or compound predicate + * @return the predicate that is the OR of the original simple or compound + * predicate and the argument. + */ + Predicate or(Predicate predicate); + + /** + * Creates a negation of the predicate with the argument. + * + * @return the predicate that is the negation of the original simple or + * compound predicate. + */ + Predicate not(); +} \ No newline at end of file diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PredicateOperand.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PredicateOperand.java new file mode 100644 index 000000000..319e0a61f --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/PredicateOperand.java @@ -0,0 +1,588 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +import java.util.Calendar; +import java.util.Date; + +/** + * Interface for constructing where-clause and having-clause conditions. + * Instances of PredicateOperand are used in constructing predicates passed to + * the where or having methods. + */ +public interface PredicateOperand { + /** + * Create a predicate for testing equality with the specified argument. + * + * @param arg - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate equal(PredicateOperand arg); + + /** + * Create a predicate for testing equality with the specified argument. + * + * @param cls - + * entity class + * @return conditional predicate + */ + Predicate equal(Class cls); + + /** + * Create a predicate for testing equality with the specified argument. + * + * @param arg - + * numeric + * @return conditional predicate + */ + Predicate equal(Number arg); + + /** + * Create a predicate for testing equality with the specified argument. + * + * @param arg - + * string value + * @return conditional predicate + */ + Predicate equal(String arg); + + /** + * Create a predicate for testing equality with the specified argument. + * + * @param arg - + * boolean value + * @return conditional predicate + */ + Predicate equal(boolean arg); + + /** + * Create a predicate for testing equality with the specified argument. + * + * @param arg - + * date + * @return conditional predicate + */ + Predicate equal(Date arg); + + /** + * Create a predicate for testing equality with the specified argument. + * + * @param arg - + * calendar + * @return conditional predicate + */ + Predicate equal(Calendar arg); + + /** + * Create a predicate for testing equality with the specified argument. + * + * @param e - + * enum + * @return conditional predicate + */ + Predicate equal(Enum e); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param arg - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate notEqual(PredicateOperand arg); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param cls - + * entity class + * @return conditional predicate + */ + Predicate notEqual(Class cls); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param arg - + * numberic value + * @return conditional predicate + */ + Predicate notEqual(Number arg); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param arg - + * string value + * @return conditional predicate + */ + Predicate notEqual(String arg); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param arg - + * boolean value + * @return conditional predicate + */ + Predicate notEqual(boolean arg); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param arg - + * date + * @return conditional predicate + */ + Predicate notEqual(Date arg); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param arg - + * calendar + * @return conditional predicate + */ + Predicate notEqual(Calendar arg); + + /** + * Create a predicate for testing inequality with the specified argument. + * + * @param e - + * enum + * @return conditional predicate + */ + Predicate notEqual(Enum e); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than the argument. + * + * @param arg - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate greaterThan(PredicateOperand arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than the argument. + * + * @param arg - + * numeric + * @return conditional predicate + */ + Predicate greaterThan(Number arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than the argument. + * + * @param arg - + * string + * @return conditional predicate + */ + Predicate greaterThan(String arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than the argument. + * + * @param arg - + * date + * @return conditional predicate + */ + Predicate greaterThan(Date arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than the argument. + * + * @param arg - + * calendar + * @return conditional predicate + */ + Predicate greaterThan(Calendar arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than or equal to the argument. + * + * @param arg - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate greaterEqual(PredicateOperand arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than or equal to the argument. + * + * @param arg - + * numeric + * @return conditional predicate + */ + Predicate greaterEqual(Number arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than or equal to the argument. + * + * @param arg - + * string + * @return conditional predicate + */ + Predicate greaterEqual(String arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than or equal to the argument. + * + * @param arg - + * date + * @return conditional predicate + */ + Predicate greaterEqual(Date arg); + + /** + * Create a predicate for testing whether the PredicateOperand is greater + * than or equal to the argument. + * + * @param arg - + * calendar + * @return conditional predicate + */ + Predicate greaterEqual(Calendar arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * the argument. + * + * @param arg - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate lessThan(PredicateOperand arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * the argument. + * + * @param arg - + * numeric + * @return conditional predicate + */ + Predicate lessThan(Number arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * the argument. + * + * @param arg - + * string + * @return conditional predicate + */ + Predicate lessThan(String arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * the argument. + * + * @param arg - + * date + * @return conditional predicate + */ + Predicate lessThan(Date arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * the argument. + * + * @param arg - + * calendar + * @return conditional predicate + */ + Predicate lessThan(Calendar arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * or equal to the argument. + * + * @param arg - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate lessEqual(PredicateOperand arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * or equal to the argument. + * + * @param arg - + * numeric + * @return conditional predicate + */ + Predicate lessEqual(Number arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * or equal to the argument. + * + * @param arg - + * string + * @return conditional predicate + */ + Predicate lessEqual(String arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * or equal to the argument. + * + * @param arg - + * date + * @return conditional predicate + */ + Predicate lessEqual(Date arg); + + /** + * Create a predicate for testing whether the PredicateOperand is less than + * or equal to the argument. + * + * @param arg - + * calendar + * @return conditional predicate + */ + Predicate lessEqual(Calendar arg); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * PredicateOperand instance or parameter + * @param arg2 - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate between(PredicateOperand arg1, PredicateOperand arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * PredicateOperand instance or parameter + * @param arg2 - + * numeric + * @return conditional predicate + */ + Predicate between(PredicateOperand arg1, Number arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * numeric + * @param arg2 - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate between(Number arg1, PredicateOperand arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * numeric + * @param arg2 - + * numeric + * @return conditional predicate + */ + Predicate between(Number arg1, Number arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * PredicateOperand instance or parameter + * @param arg2 - + * string + * @return conditional predicate + */ + Predicate between(PredicateOperand arg1, String arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * string + * @param arg2 - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate between(String arg1, PredicateOperand arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * string + * @param arg2 - + * string + * @return conditional predicate + */ + Predicate between(String arg1, String arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * PredicateOperand instance or parameter + * @param arg2 - + * date + * @return conditional predicate + */ + Predicate between(PredicateOperand arg1, Date arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * date + * @param arg2 - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate between(Date arg1, PredicateOperand arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * date + * @param arg2 - + * date + * @return conditional predicate + */ + Predicate between(Date arg1, Date arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * PredicateOperand instance or parameter + * @param arg2 - + * calendar + * @return conditional predicate + */ + Predicate between(PredicateOperand arg1, Calendar arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * calendar + * @param arg2 - + * PredicateOperand instance or parameter + * @return conditional predicate + */ + Predicate between(Calendar arg1, PredicateOperand arg2); + + /** + * Create a predicate for testing whether the PredicateOperand lies between + * (inclusive) the two arguments. + * + * @param arg1 - + * calendar + * @param arg2 - + * calendar + * @return conditional predicate + */ + Predicate between(Calendar arg1, Calendar arg2); + + /** + * Create a predicate for testing whether the PredicateOperand satisfies the + * given pattern. + * + * @param pattern + * @return conditional predicate + */ + Predicate like(PredicateOperand pattern); + + /** + * Create a predicate for testing whether the PredicateOperand satisfies the + * given pattern. + * + * @param pattern + * @param escapeChar + * @return conditional predicate + */ + Predicate like(PredicateOperand pattern, PredicateOperand escapeChar); + + /** + * Create a predicate for testing whether the PredicateOperand satisfies the + * given pattern. + * + * @param pattern + * @param escapeChar + * @return conditional predicate + */ + Predicate like(PredicateOperand pattern, char escapeChar); + + /** + * Create a predicate for testing whether the PredicateOperand satisfies the + * given pattern. + * + * @param pattern + * @return conditional predicate + */ + Predicate like(String pattern); + + /** + * Create a predicate for testing whether the PredicateOperand satisfies the + * given pattern. + * + * @param pattern + * @param escapeChar + * @return conditional predicate + */ + Predicate like(String pattern, PredicateOperand escapeChar); + + /** + * Create a predicate for testing whether the PredicateOperand satisfies the + * given pattern. + * + * @param pattern + * @param escapeChar + * @return conditional predicate + */ + Predicate like(String pattern, char escapeChar); +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilder.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilder.java new file mode 100644 index 000000000..78882181c --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilder.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * Factory interface for query definition objects + */ +public interface QueryBuilder { + /** + * Create an uninitialized query definition object. + * + * @return query definition instance + */ + QueryDefinition createQueryDefinition(); + + /** + * Create a query definition object with the given root. The root must be an + * entity class. + * + * @param cls - + * an entity class + * @return root domain object + */ + DomainObject createQueryDefinition(Class root); + + /** + * Create a query definition object whose root is derived from a domain + * object of the containing query. Provides support for correlated + * subqueries. Joins against the resulting domain object do not affect the + * query domain of the containing query. The path expression must correspond + * to an entity class. The path expression must not be a domain object of + * the containing query. + * + * @param path - + * path expression corresponding to the domain object used to + * derive the subquery root. + * @return the subquery DomainObject + */ + DomainObject createSubqueryDefinition(PathExpression path); +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilderImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilderImpl.java index 541280103..0828cd9c0 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilderImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryBuilderImpl.java @@ -18,11 +18,7 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.DomainObject; -import javax.persistence.PathExpression; -import javax.persistence.Query; -import javax.persistence.QueryDefinition; - +import org.apache.openjpa.kernel.Query; import org.apache.openjpa.meta.MetaDataRepository; import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinition.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinition.java new file mode 100644 index 000000000..a22480d4a --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinition.java @@ -0,0 +1,556 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * Interface for construction of query definitions + */ +public interface QueryDefinition extends Subquery { + /** + * Add a query root corresponding to the given entity, forming a cartesian + * product with any existing roots. The domain object that is returned is + * bound as a component of the given query. The argument must be an entity + * class. + * + * @param cls - + * an entity class + * @return DomainObject corresponding to the specified entity class. + */ + DomainObject addRoot(Class cls); + + /** + * Add a root derived from a domain object of the containing query + * definition to a query definition used as a subquery. Provides support for + * correlated subqueries. Joins against the resulting domain object do not + * affect the query domain of the containing query. The path expression must + * correspond to an entity class. The path expression must not be a domain + * object of the containing query. + * + * @param path - + * path expression corresponding to the domain object used to + * derive the subquery root. + * @return the subquery DomainObject + */ + DomainObject addSubqueryRoot(PathExpression path); + + /** + * Specify the objects / values to be returned. Replaces the previous select + * list, if any. If no select items are specified and there is only one + * query root, the root entity is assumed to be the result. + * + * @param selectItems - + * one or more SelectItem instances + * @return the modified query definition instance + */ + QueryDefinition select(SelectItem... selectItems); + + /** + * Specify the objects / values to be returned. Replaces the previous select + * list, if any. If no select items are specified and there is only one + * query root, the root entity is assumed to be the result. + * + * @param selectItemList - + * a list containing one or more SelectItem instances + * @return the modified query definition instance + */ + QueryDefinition select(List selectItemList); + + /** + * Specify the objects / values to be returned. Duplicate results will be + * eliminated. Replaces the previous select list, if any. If no select items + * are specified and there is only one query root, the root entity is + * assumed to be the result. + * + * @param selectItems - + * one or more SelectItem instances + * @return the modified query definition instance + */ + QueryDefinition selectDistinct(SelectItem... selectItems); + + /** + * Specify the objects / values to be returned. Duplicate results will be + * eliminated. Replaces the previous select list, if any. If no select items + * are specified, and there is only one query root, the root entity is + * assumed to be the result. is assumed to be the result. + * + * @param selectItemList - + * a list containing one or more SelectItem instances + * @return the modified query definition instance + */ + QueryDefinition selectDistinct(List selectItemList); + + /** + * Modifies the query definition to restrict the result of the query + * according to the specified predicate. Replaces the previously added + * restriction(s), if any. + * + * @param predicate - + * a simple or compound conditional predicate + * @return the modified QueryDefinition instance + */ + QueryDefinition where(Predicate predicate); + + /** + * Specify the items of the select list that are used in ordering the query + * results. Replaces the previous order-by list, if any. + * + * @param orderByItems - + * one or more OrderByItem instances + * @return the modified QueryDefinition instance + */ + QueryDefinition orderBy(OrderByItem... orderByItems); + + /** + * Specify the items of the select list that are used in ordering the query + * results. Replaces the previous order-by list, if any. + * + * @param orderByItemList - + * a list containing one or more OrderByItem instances + * @return the modified QueryDefinition instance + */ + QueryDefinition orderBy(List orderByItemList); + + /** + * Specify the items that are used to form groups over the query results. + * Replaces the previous group-by list, if any. + * + * @param pathExprs + * @return the modified QueryDefinition instance + */ + QueryDefinition groupBy(PathExpression... pathExprs); + + /** + * Specify the items that are used to form groups over the query results. + * Replaces the previous group-by list, if any. + * + * @param pathExprList + * @return the modified QueryDefinition instance + */ + QueryDefinition groupBy(List pathExprList); + + /** + * Specify the restrictions over the groups of a query. Replaces the + * previous having restriction(s), if any. + * + * @param predicate + * @return the modified QueryDefinition Instance + */ + QueryDefinition having(Predicate predicate); + + /** + * Specify that a constructor for the given class is to be applied to the + * corresponding query results after the query is executed. The class must + * have a constructor that accepts the Java argument types corresponding to + * the given select items. + * + * @param cls - + * a class with the correponding constructor + * @param args - + * select items that correspond to result types that are valid as + * arguments to the constructor + * @result SelectItem instance representing the constructor + */ + SelectItem newInstance(Class cls, SelectItem... args); + + /** + * Use the query definition instance as a subquery in an exists predicate. + * + * @return the resulting predicate + */ + Predicate exists(); + + /** + * Use the query definition object in a subquery in an all expression. + * + * @return the resulting Subquery + */ + Subquery all(); + + /** + * Use the query definition object in a subquery in an any expression. + * + * @return the resulting Subquery + */ + Subquery any(); + + /** + * Use the query definition object in a subquery in a some expression. + * + * @return the resulting Subquery + */ + Subquery some(); + + /** + * Create an empty general case expression. A general case expression is of + * the form: + *

+ * generalCase() .when(conditional-predicate).then(scalar-expression) + * .when(conditional-predicate).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @return empty general case expression + */ + CaseExpression generalCase(); + + /** + * Create a simple case expression with the given case operand. A simple + * case expression is of the form: + *

+ * simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) + * .when(scalar-expression).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @param caseOperand - + * expression used for testing against the when scalar + * expressions + * @return case expression with the given case operand + */ + CaseExpression simpleCase(Expression caseOperand); + + /** + * Create a simple case expression with the given case operand. A simple + * case expression is of the form: + *

+ * simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) + * .when(scalar-expression).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @param caseOperand - + * numeric value used for testing against the when scalar + * expressions + * @return case expression with the given case operand + */ + CaseExpression simpleCase(Number caseOperand); + + /** + * Create a simple case expression with the given case operand. A simple + * case expression is of the form: + *

+ * simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) + * .when(scalar-expression).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @param caseOperand - + * value used for testing against the when scalar expressions + * @return case expression with the given case operand + */ + CaseExpression simpleCase(String caseOperand); + + /** + * Create a simple case expression with the given case operand. A simple + * case expression is of the form: + *

+ * simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) + * .when(scalar-expression).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @param caseOperand - + * value used for testing against the when scalar expressions + * @return case expression with the given case operand + */ + CaseExpression simpleCase(Date caseOperand); + + /** + * Create a simple case expression with the given case operand. A simple + * case expression is of the form: + *

+ * simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) + * .when(scalar-expression).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @param caseOperand - + * value used for testing against the when scalar expressions + * @return case expression with the given case operand + */ + CaseExpression simpleCase(Calendar caseOperand); + + /** + * Create a simple case expression with the given case operand. A simple + * case expression is of the form: + *

+ * simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) + * .when(scalar-expression).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @param caseOperand - + * value used for testing against the when scalar expressions + * @return case expression with the given case operand + */ + CaseExpression simpleCase(Class caseOperand); + + /** + * Create a simple case expression with the given case operand. A simple + * case expression is of the form: + *

+ * simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) + * .when(scalar-expression).then(scalar-expression) ... + * .elseCase(scalar-expression) + * + * @param caseOperand - + * value used for testing against the when scalar expressions + * @return case expression with the given case operand + */ + CaseExpression simpleCase(Enum caseOperand); + + /** + * coalesce This is equivalent to a case expression that returns null if all + * its arguments evaluate to null, and the value of its first non-null + * argument otherwise. + * + * @param exp - + * expressions to be used for testing against null + * @return Expression corresponding to the given coalesce expression + */ + Expression coalesce(Expression... exp); + + /** + * coalesce This is equivalent to a case expression that returns null if all + * its arguments evaluate to null, and the value of its first non-null + * argument otherwise. + * + * @param exp - + * expressions to be used for testing against null + * @return Expression corresponding to the given coalesce expression + */ + Expression coalesce(String... exp); + + /** + * coalesce This is equivalent to a case expression that returns null if all + * its arguments evaluate to null, and the value of its first non-null + * argument otherwise. + * + * @param exp - + * expressions to be used for testing against null + * @return Expression corresponding to the given coalesce expression + */ + Expression coalesce(Date... exp); + + /** + * coalesce This is equivalent to a case expression that returns null if all + * its arguments evaluate to null, and the value of its first non-null + * argument otherwise. + * + * @param exp - + * expressions to be used for testing against null + * @return Expression corresponding to the given coalesce expression + */ + Expression coalesce(Calendar... exp); + + /** + * nullif This is equivalent to a case expression that tests whether its + * arguments are equal, returning null if they are and the value of the + * first expression if they are not. + * + * @param exp1 + * @param exp2 + * @return Expression corresponding to the given nullif expression + */ + Expression nullif(Expression exp1, Expression exp2); + + /** + * nullif This is equivalent to a case expression that tests whether its + * arguments are equal, returning null if they are and the value of the + * first expression if they are not. + * + * @param arg1 + * @param arg2 + * @return Expression corresponding to the given nullif expression + */ + Expression nullif(Number arg1, Number arg2); + + /** + * nullif This is equivalent to a case expression that tests whether its + * arguments are equal, returning null if they are and the value of the + * first expression if they are not. + * + * @param arg1 + * @param arg2 Criteria API Java Persistence 2.0, Public Review Draft + * Criteria API Interfaces 10/31/08 158 JSR-317 Public Review + * Draft Sun Microsystems, Inc. + * @return Expression corresponding to the given nullif expression + */ + Expression nullif(String arg1, String arg2); + + /** + * nullif This is equivalent to a case expression that tests whether its + * arguments are equal, returning null if they are and the value of the + * first expression if they are not. + * + * @param arg1 + * @param arg2 + * @return Expression corresponding to the given nullif expression + */ + Expression nullif(Date arg1, Date arg2); + + /** + * nullif This is equivalent to a case expression that tests whether its + * arguments are equal, returning null if they are and the value of the + * first expression if they are not. + * + * @param arg1 + * @param arg2 + * @return Expression corresponding to the given nullif expression + */ + Expression nullif(Calendar arg1, Calendar arg2); + + /** + * nullif This is equivalent to a case expression that tests whether its + * arguments are equal, returning null if they are and the value of the + * first expression if they are not. + * + * @param arg1 + * @param arg2 + * @return Expression corresponding to the given nullif expression + */ + Expression nullif(Class arg1, Class arg2); + + /** + * nullif This is equivalent to a case expression that tests whether its + * arguments are equal, returning null if they are and the value of the + * first expression if they are not. + * + * @param arg1 + * @param arg2 + * @return Expression corresponding to the given nullif expression + */ + Expression nullif(Enum arg1, Enum arg2); + + /** + * Create a predicate value from the given boolean. + * + * @param b boolean value + * @return a true or false predicate + */ + Predicate predicate(boolean b); + + /** + * Create an Expression corresponding to the current time on the database + * server at the time of query execution. + * + * @return the corresponding Expression + */ + Expression currentTime(); + + /** + * Create an Expression corresponding to the current date on the database + * server at the time of query execution. + * + * @return the corresponding Expression + */ + Expression currentDate(); + + /** + * Create an Expression corresponding to the current timestamp on the + * database server at the time of query execution. + * + * @return the corresponding Expression + */ + Expression currentTimestamp(); + + /** + * Create an Expression corresponding to a String value. + * + * @param s - + * string value + * @return the corresponding Expression literal + */ + Expression literal(String s); + + /** + * Create an Expression corresponding to a numeric value. + * + * @param n - + * numeric value + * @return the corresponding Expression literal + */ + Expression literal(Number n); + + /** + * Create an Expression corresponding to a boolean value. + * + * @param b - + * boolean value + * @return the corresponding Expression literal + */ + Expression literal(boolean b); + + /** + * Create an Expression corresponding to a Calendar value. + * + * @param c - + * Calendar value + * @return the corresponding Expression literal + */ + Expression literal(Calendar c); + + /** + * Create an Expression corresponding to a Date value. + * + * @param d - + * Date value + * @return the corresponding Expression literal + */ + Expression literal(Date d); + + /** + * Create an Expression corresponding to a character value. + * + * @param character value + * @return the corresponding Expression literal + */ + Expression literal(char c); + + /** + * Create an Expression corresponding to an entity class. + * + * @param cls - + * entity class + * @return the corresponding Expression literal + */ + Expression literal(Class cls); + + /** + * Create an Expression corresponding to an enum. + * + * @param e - + * enum + * @return the corresponding Expression literal + */ + Expression literal(Enum e); + + /** + * Create an Expression corresponding to a null value. + * + * @return the corresponding Expression literal + */ + Expression nullLiteral(); + + /** + * Specify use of a parameter of the given name. + * + * @param parameter name + * @return an Expression corresponding to a named parameter + */ + Expression param(String name); +} \ No newline at end of file diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinitionImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinitionImpl.java index 3ad628b1f..589f70a3a 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinitionImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryDefinitionImpl.java @@ -29,16 +29,6 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; -import javax.persistence.CaseExpression; -import javax.persistence.DomainObject; -import javax.persistence.Expression; -import javax.persistence.OrderByItem; -import javax.persistence.PathExpression; -import javax.persistence.Predicate; -import javax.persistence.QueryDefinition; -import javax.persistence.SelectItem; -import javax.persistence.Subquery; - import org.apache.openjpa.lib.util.Localizer; /** diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryExpression.java index f25e50b81..2b3558a2e 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/QueryExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Subquery; - /** * An expression resulting from operation on a query itself. Can be used as a * subquery clause in a parent query. diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RangeExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RangeExpression.java index 0f5a5d067..06edac0b2 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RangeExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RangeExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes a range used by e1 BETWEEN x AND y operation. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RootPath.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RootPath.java index b508e0d7c..2b1a1cdac 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RootPath.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/RootPath.java @@ -1,7 +1,5 @@ package org.apache.openjpa.persistence.query; -import javax.persistence.DomainObject; - /** * Denotes root domain instance representing a persistent type. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SelectItem.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SelectItem.java new file mode 100644 index 000000000..a180151d3 --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SelectItem.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * SelectItem instances are used in specifying the query's select list. + *

+ * The methods of this interface are used to define arguments that can be passed + * to the orderBy method for use in ordering selected items of the query result. + */ +public interface SelectItem extends OrderByItem { + /** + * Return an OrderByItem referencing the SelectItem and specifying ascending + * ordering. The SelectItem must correspond to an orderable value. + * + * @return order-by item + */ + OrderByItem asc(); + + /** + * Return an OrderByItem referencing the SelectItem and specifying + * descending ordering. The SelectItem must correspond to an orderable + * value. + * + * @return order-by item + */ + OrderByItem desc(); +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SizeExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SizeExpression.java index 6e8b19d3f..43de5de43 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SizeExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SizeExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes SIZE(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SomeExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SomeExpression.java index 689eb9c51..08d142e35 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SomeExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SomeExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Subquery; - /** * Denotes SOME(Subquery) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SquareRootExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SquareRootExpression.java index b481d058f..1f8e547e1 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SquareRootExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SquareRootExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes SQRT(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SubStringExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SubStringExpression.java index 6f4328c8f..174bae704 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SubStringExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SubStringExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes SUBSTR(a,i1,i2) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Subquery.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Subquery.java new file mode 100644 index 000000000..2758a5750 --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/Subquery.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * Instances of this interface can be used as subqueries. + */ +public interface Subquery extends PredicateOperand { +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SumExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SumExpression.java index 9f4d23e2c..f7b66a0f3 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SumExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/SumExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes SUM(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TimesExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TimesExpression.java index 3414bc9ee..14437cef2 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TimesExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TimesExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes (e1*e2) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimExpression.java index 83a888633..0b7c0fa8a 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimExpression.java @@ -18,9 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; -import javax.persistence.TrimSpec; - /** * Denotes TRIM(e1,x) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimSpec.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimSpec.java new file mode 100644 index 000000000..43f7d34cd --- /dev/null +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TrimSpec.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.persistence.query; + +/** + * Used to specify the trimming of strings + */ +public enum TrimSpec { + LEADING, TRAILING, BOTH +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TypeExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TypeExpression.java index 3869f72a1..4b8d5ef2f 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TypeExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/TypeExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes TYPE(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryExpressionPredicate.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryExpressionPredicate.java index 463450c5e..38145d467 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryExpressionPredicate.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryExpressionPredicate.java @@ -18,9 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; -import javax.persistence.Predicate; - /** * Unary Predicate results from an operator on an Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryMinusExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryMinusExpression.java index c8e0469c1..74916bf33 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryMinusExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryMinusExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes (-e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryOperatorExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryOperatorExpression.java index 57933500d..fbe5a6a0c 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryOperatorExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UnaryOperatorExpression.java @@ -18,9 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Aggregate; -import javax.persistence.Expression; - class UnaryOperatorExpression extends ExpressionImpl implements Aggregate { protected final Expression _e; protected final UnaryFunctionalOperator _op; diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UpperExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UpperExpression.java index 90d7566e5..0a88921c1 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UpperExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/UpperExpression.java @@ -18,8 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import javax.persistence.Expression; - /** * Denotes UPPER(e) Expression. * diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/VarArgsExpression.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/VarArgsExpression.java index 5e7e8b82b..cde66fc5d 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/VarArgsExpression.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/VarArgsExpression.java @@ -18,10 +18,6 @@ */ package org.apache.openjpa.persistence.query; -import java.util.Arrays; - -import javax.persistence.Expression; - /** * A expression that holds an array of Expressions. Used as operand for * CONCAT(e1,e2,e3,...), for example. Different than {@link ArrayExpression}