Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_jpql_validation.properties15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaJpqlQueryHelper.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaJpqlQueryHelper.java31
3 files changed, 74 insertions, 9 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_jpql_validation.properties b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_jpql_validation.properties
index 385981b6ad..58cf483f2e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_jpql_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_jpql_validation.properties
@@ -200,10 +200,14 @@ EXISTS_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing fro
EXISTS_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the EXISTS expression.
# FunctionExpression - Grammar
-FUNCTION_EXPRESSION_INVALID_EXPRESSION = The argument is not valid.
-FUNCTION_EXPRESSION_MISSING_FUNCTION_NAME = The SQL function name must be specified.
-FUNCTION_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the expression.
-FUNCTION_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the expression.
+FUNCTION_EXPRESSION_HAS_EXPRESSION = The function {0} should not have any argument.
+FUNCTION_EXPRESSION_INVALID_EXPRESSION = The function {0}''s argument is not valid.
+FUNCTION_EXPRESSION_MISSING_EXPRESSION = The function {0}''s argument must be specified.
+FUNCTION_EXPRESSION_MISSING_FUNCTION_NAME = The function name must be specified.
+FUNCTION_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the function {0}.
+FUNCTION_EXPRESSION_MISSING_ONE_EXPRESSION = The function {0} must have one argument specified.
+FUNCTION_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the function {0}.
+FUNCTION_EXPRESSION_MORE_THAN_ONE_EXPRESSION = The function {0} has more than one argument, can only specify one argument.
# GroupByClause - Grammar
GROUP_BY_CLAUSE_GROUP_BY_ITEM_ENDS_WITH_COMMA = The select expression cannot end with a comma.
@@ -401,9 +405,6 @@ RESULT_VARIABLE_INVALID_JPA_VERSION = A result variable cannot be used in a JPQL
RESULT_VARIABLE_MISSING_SELECT_EXPRESSION = The select item is missing from the result variable declaration.
RESULT_VARIABLE_MISSING_RESULT_VARIABLE = The result variable is missing from the select item declaration.
-# SelectStatement - Semantic
-SELECT_STATEMENT_SELECT_CLAUSE_HAS_NON_AGGREGATE_FUNCTIONS = The select list can only consist of aggregate functions because there is no GROUP BY clause and the HAVING clause is used.
-
# SimpleSelectClause - Grammar
SIMPLE_SELECT_CLAUSE_NOT_SINGLE_EXPRESSION = Only one expression can be declared in a SELECT clause of a subquery.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaJpqlQueryHelper.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaJpqlQueryHelper.java
index da1d382742..7c0e962330 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaJpqlQueryHelper.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaJpqlQueryHelper.java
@@ -24,10 +24,17 @@ import org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator;
import org.eclipse.persistence.jpa.jpql.DefaultContentAssistVisitor;
import org.eclipse.persistence.jpa.jpql.DefaultGrammarValidator;
import org.eclipse.persistence.jpa.jpql.DefaultJPQLQueryContext;
+import org.eclipse.persistence.jpa.jpql.DefaultRefactoringTool;
import org.eclipse.persistence.jpa.jpql.DefaultSemanticValidator;
import org.eclipse.persistence.jpa.jpql.JPQLQueryContext;
+import org.eclipse.persistence.jpa.jpql.RefactoringTool;
+import org.eclipse.persistence.jpa.jpql.model.IJPQLQueryBuilder;
+import org.eclipse.persistence.jpa.jpql.model.JPQLQueryBuilder1_0;
+import org.eclipse.persistence.jpa.jpql.model.JPQLQueryBuilder2_0;
+import org.eclipse.persistence.jpa.jpql.model.JPQLQueryBuilder2_1;
import org.eclipse.persistence.jpa.jpql.parser.JPQLGrammar;
import org.eclipse.persistence.jpa.jpql.spi.IMappingBuilder;
+import org.eclipse.persistence.jpa.jpql.spi.IQuery;
/**
* The default implementation of {@link JpaJpqlQueryHelper} that provides support based on the Java
@@ -61,7 +68,7 @@ public class GenericJpaJpqlQueryHelper extends JpaJpqlQueryHelper {
*/
@Override
protected AbstractGrammarValidator buildGrammarValidator(JPQLQueryContext queryContext) {
- return new DefaultGrammarValidator(queryContext);
+ return new DefaultGrammarValidator(queryContext.getGrammar());
}
/**
@@ -89,6 +96,34 @@ public class GenericJpaJpqlQueryHelper extends JpaJpqlQueryHelper {
}
/**
+ * Creates the right {@link IJPQLQueryBuilder} based on the JPQL grammar.
+ *
+ * @return A new concrete instance of {@link IJPQLQueryBuilder}
+ */
+ protected IJPQLQueryBuilder buildQueryBuilder() {
+ switch (getGrammar().getJPAVersion()) {
+ case VERSION_1_0: return new JPQLQueryBuilder1_0();
+ case VERSION_2_0: return new JPQLQueryBuilder2_0();
+ default: return new JPQLQueryBuilder2_1();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RefactoringTool buildRefactoringTool() {
+
+ IQuery query = getQuery();
+
+ return new DefaultRefactoringTool(
+ query.getProvider(),
+ buildQueryBuilder(),
+ query.getExpression()
+ );
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaJpqlQueryHelper.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaJpqlQueryHelper.java
index 82ebbb2e39..6af4aa7100 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaJpqlQueryHelper.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaJpqlQueryHelper.java
@@ -21,13 +21,18 @@ import org.eclipse.jpt.jpa.eclipselink.core.jpql.spi.EclipseLinkMappingBuilder;
import org.eclipse.persistence.jpa.jpql.AbstractContentAssistVisitor;
import org.eclipse.persistence.jpa.jpql.AbstractGrammarValidator;
import org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator;
+import org.eclipse.persistence.jpa.jpql.DefaultRefactoringTool;
import org.eclipse.persistence.jpa.jpql.EclipseLinkContentAssistVisitor;
import org.eclipse.persistence.jpa.jpql.EclipseLinkGrammarValidator;
import org.eclipse.persistence.jpa.jpql.EclipseLinkJPQLQueryContext;
import org.eclipse.persistence.jpa.jpql.EclipseLinkSemanticValidator;
import org.eclipse.persistence.jpa.jpql.JPQLQueryContext;
+import org.eclipse.persistence.jpa.jpql.RefactoringTool;
+import org.eclipse.persistence.jpa.jpql.model.EclipseLinkJPQLQueryBuilder;
+import org.eclipse.persistence.jpa.jpql.model.IJPQLQueryBuilder;
import org.eclipse.persistence.jpa.jpql.parser.JPQLGrammar;
import org.eclipse.persistence.jpa.jpql.spi.IMappingBuilder;
+import org.eclipse.persistence.jpa.jpql.spi.IQuery;
/**
* The abstract implementation of {@link JpaJpqlQueryHelper} that supports EclipseLink.
@@ -60,7 +65,7 @@ public class EclipseLinkJpaJpqlQueryHelper extends JpaJpqlQueryHelper {
*/
@Override
protected AbstractGrammarValidator buildGrammarValidator(JPQLQueryContext queryContext) {
- return new EclipseLinkGrammarValidator(queryContext);
+ return new EclipseLinkGrammarValidator(queryContext.getGrammar());
}
/**
@@ -88,6 +93,30 @@ public class EclipseLinkJpaJpqlQueryHelper extends JpaJpqlQueryHelper {
}
/**
+ * Creates the right {@link IJPQLQueryBuilder} based on the JPQL grammar.
+ *
+ * @return A new concrete instance of {@link IJPQLQueryBuilder}
+ */
+ protected IJPQLQueryBuilder buildQueryBuilder() {
+ return new EclipseLinkJPQLQueryBuilder(getGrammar());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RefactoringTool buildRefactoringTool() {
+
+ IQuery query = getQuery();
+
+ return new DefaultRefactoringTool(
+ query.getProvider(),
+ buildQueryBuilder(),
+ query.getExpression()
+ );
+ }
+
+ /**
* {@inheritDoc}
*/
@Override

Back to the top