You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2026/09/28 13:00:38 UTC
(cayenne) branch master updated (942803a46 -> 040e3c746)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
from 942803a46 CAY-3039 Refactor Expressions to be independent from the parser syntax
new 276b766eb CAY-3039 Refactor Expressions to be independent from the parser syntax
new 040e3c746 CAY-3038 Remove EJBQLQuery
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.claude/rules/cayenne/architecture.md | 1 -
RELEASE-NOTES.txt | 1 +
UPGRADE.md | 15 +
ai-plugin/references/datamap-schema.md | 8 -
ai-plugin/references/model-naming-rename-safety.md | 6 +-
ai-plugin/skills/cayenne-model-naming/SKILL.md | 6 +-
cayenne-ant/src/test/resources/testmap.map.xml | 5 -
.../org/apache/cayenne/gen/DataMapArtifact.java | 1 -
.../cayenne/dbsync/naming/NameBuilderTest.java | 2 +-
.../src/test/resources/cgen/output/testmap.map.xml | 5 -
.../cayenne/modeler/ui/action/FindAction.java | 2 -
.../cayenne/modeler/ui/action/RemoveAction.java | 9 +-
.../modeler/ui/project/editor/EditorPanelView.java | 12 -
.../editor/query/ejbql/EjbqlQueryMainTab.java | 173 ---
.../query/ejbql/EjbqlQueryPropertiesPanel.java | 65 -
.../editor/query/ejbql/EjbqlQueryScriptsTab.java | 263 ----
.../ui/project/editor/query/ejbql/EjbqlSyntax.java | 67 --
.../editor/query/ejbql/EjbqlTabbedView.java | 87 --
.../ui/project/querytype/QueryTypeDialog.java | 9 +-
.../cayenne/modeler/undo/TextCompoundEdit.java | 5 -
.../validation/DefaultProjectValidator.java | 5 -
.../project/validation/EJBQLQueryValidator.java | 50 -
.../validation/EJBQLStatementValidator.java | 169 ---
.../cayenne/project/validation/Inspection.java | 3 -
.../apache/cayenne/velocity/ResultDirective.java | 6 +-
cayenne/pom.xml | 71 +-
.../java/org/apache/cayenne/access/DataNode.java | 16 -
.../org/apache/cayenne/access/DataRowStore.java | 2 +-
.../org/apache/cayenne/access/ObjectResolver.java | 3 +-
.../apache/cayenne/access/jdbc/EJBQLAction.java | 184 ---
.../jdbc/reader/DefaultRowReaderFactory.java | 4 +-
.../cayenne/access/translator/EJBQLTranslator.java | 56 -
.../ejbql/DbAdapterDelegatedEJBQLTranslator.java | 96 --
.../ejbql/EJBQLAggregateColumnTranslator.java | 192 ---
.../translator/ejbql/EJBQLConditionTranslator.java | 1180 ------------------
.../translator/ejbql/EJBQLDbPathTranslator.java | 286 -----
.../translator/ejbql/EJBQLDeleteTranslator.java | 56 -
.../translator/ejbql/EJBQLFromTranslator.java | 112 --
.../translator/ejbql/EJBQLGroupByTranslator.java | 124 --
.../translator/ejbql/EJBQLIdColumnsTranslator.java | 62 -
.../ejbql/EJBQLIdentifierColumnsTranslator.java | 255 ----
.../access/translator/ejbql/EJBQLJoinAppender.java | 357 ------
.../translator/ejbql/EJBQLMultiColumnOperand.java | 92 --
.../translator/ejbql/EJBQLOrderByTranslator.java | 83 --
.../translator/ejbql/EJBQLPathTranslator.java | 331 -----
.../ejbql/EJBQLSelectColumnsTranslator.java | 244 ----
.../translator/ejbql/EJBQLSelectTranslator.java | 116 --
.../access/translator/ejbql/EJBQLTableId.java | 144 ---
.../translator/ejbql/EJBQLTranslationContext.java | 526 --------
.../ejbql/EJBQLUpdateItemTranslator.java | 124 --
.../translator/ejbql/EJBQLUpdateTranslator.java | 74 --
.../translator/ejbql/JdbcEJBQLTranslator.java | 105 --
.../cayenne/configuration/runtime/CoreModule.java | 3 -
.../runtime/DefaultDataNodeFactory.java | 5 -
.../configuration/upgrade/UpgradeHandler_V14.java | 23 +-
.../configuration/upgrade/UpgradeHandler_V8.java | 2 +-
.../configuration/xml/QueryDescriptorHandler.java | 6 -
.../java/org/apache/cayenne/dba/AutoAdapter.java | 9 -
.../java/org/apache/cayenne/dba/DbAdapter.java | 16 -
.../org/apache/cayenne/dba/JdbcActionBuilder.java | 10 -
.../java/org/apache/cayenne/dba/JdbcAdapter.java | 48 -
.../org/apache/cayenne/dba/db2/DB2Adapter.java | 12 -
.../dba/db2/DB2EJBQLConditionTranslator.java | 54 -
.../apache/cayenne/dba/db2/DB2EJBQLTranslator.java | 37 -
.../org/apache/cayenne/dba/derby/DerbyAdapter.java | 12 -
.../dba/derby/DerbyEJBQLConditionTranslator.java | 55 -
.../cayenne/dba/derby/DerbyEJBQLTranslator.java | 36 -
.../cayenne/dba/firebird/FirebirdAdapter.java | 9 -
.../firebird/FirebirdEJBQLConditionTranslator.java | 105 --
.../dba/firebird/FirebirdEJBQLTranslator.java | 37 -
.../java/org/apache/cayenne/dba/h2/H2Adapter.java | 13 -
.../cayenne/dba/h2/H2EJBQLConditionTranslator.java | 66 -
.../apache/cayenne/dba/h2/H2EJBQLTranslator.java | 35 -
.../apache/cayenne/dba/hsqldb/HSQLDBAdapter.java | 12 -
.../dba/hsqldb/HSQLEJBQLConditionTranslator.java | 65 -
.../cayenne/dba/hsqldb/HSQLEJBQLTranslator.java | 35 -
.../org/apache/cayenne/dba/mysql/MySQLAdapter.java | 12 -
.../dba/mysql/MySQLEJBQLConditionTranslator.java | 94 --
.../cayenne/dba/mysql/MySQLEJBQLTranslator.java | 35 -
.../apache/cayenne/dba/oracle/OracleAdapter.java | 9 -
.../dba/oracle/OracleEJBQLConditionTranslator.java | 97 --
.../cayenne/dba/oracle/OracleEJBQLTranslator.java | 34 -
.../cayenne/dba/sqlserver/SQLServerAdapter.java | 6 -
.../SQLServerEJBQLConditionTranslator.java | 50 -
.../SQLServerEJBQLSubselectTranslator.java | 45 -
.../dba/sqlserver/SQLServerEJBQLTranslator.java | 31 -
.../apache/cayenne/dba/sybase/SybaseAdapter.java | 9 -
.../dba/sybase/SybaseEJBQLConditionTranslator.java | 50 -
.../dba/sybase/SybaseEJBQLSubselectTranslator.java | 45 -
.../cayenne/dba/sybase/SybaseEJBQLTranslator.java | 31 -
.../org/apache/cayenne/ejbql/EJBQLBaseVisitor.java | 409 -------
.../cayenne/ejbql/EJBQLCompiledExpression.java | 72 --
.../org/apache/cayenne/ejbql/EJBQLException.java | 51 -
.../org/apache/cayenne/ejbql/EJBQLExpression.java | 53 -
.../cayenne/ejbql/EJBQLExpressionVisitor.java | 359 ------
.../java/org/apache/cayenne/ejbql/EJBQLParser.java | 41 -
.../apache/cayenne/ejbql/EJBQLParserFactory.java | 53 -
.../ejbql/parser/AggregateConditionNode.java | 42 -
.../cayenne/ejbql/parser/CompiledExpression.java | 113 --
.../org/apache/cayenne/ejbql/parser/Compiler.java | 652 ----------
.../org/apache/cayenne/ejbql/parser/EJBQLAbs.java | 42 -
.../ejbql/parser/EJBQLAbstractSchemaName.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLAdd.java | 42 -
.../cayenne/ejbql/parser/EJBQLAggregate.java | 36 -
.../cayenne/ejbql/parser/EJBQLAggregateColumn.java | 35 -
.../org/apache/cayenne/ejbql/parser/EJBQLAll.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLAnd.java | 47 -
.../org/apache/cayenne/ejbql/parser/EJBQLAny.java | 36 -
.../cayenne/ejbql/parser/EJBQLAscending.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLAverage.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLBetween.java | 42 -
.../cayenne/ejbql/parser/EJBQLBooleanLiteral.java | 36 -
.../cayenne/ejbql/parser/EJBQLClassName.java | 37 -
.../apache/cayenne/ejbql/parser/EJBQLConcat.java | 42 -
.../cayenne/ejbql/parser/EJBQLConstructor.java | 36 -
.../ejbql/parser/EJBQLConstructorParameter.java | 36 -
.../ejbql/parser/EJBQLConstructorParameters.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLCount.java | 46 -
.../cayenne/ejbql/parser/EJBQLCurrentDate.java | 36 -
.../cayenne/ejbql/parser/EJBQLCurrentTime.java | 36 -
.../ejbql/parser/EJBQLCurrentTimestamp.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLDbPath.java | 39 -
.../cayenne/ejbql/parser/EJBQLDecimalLiteral.java | 40 -
.../apache/cayenne/ejbql/parser/EJBQLDelete.java | 36 -
.../cayenne/ejbql/parser/EJBQLDescending.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLDistinct.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLDivide.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLEquals.java | 42 -
.../cayenne/ejbql/parser/EJBQLEscapeCharacter.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLExists.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLFrom.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLFromItem.java | 96 --
.../cayenne/ejbql/parser/EJBQLGreaterOrEqual.java | 42 -
.../cayenne/ejbql/parser/EJBQLGreaterThan.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLGroupBy.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLHaving.java | 36 -
.../ejbql/parser/EJBQLIdentificationVariable.java | 36 -
.../cayenne/ejbql/parser/EJBQLIdentifier.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLIn.java | 42 -
.../cayenne/ejbql/parser/EJBQLInnerFetchJoin.java | 47 -
.../cayenne/ejbql/parser/EJBQLInnerJoin.java | 36 -
.../cayenne/ejbql/parser/EJBQLIntegerLiteral.java | 40 -
.../apache/cayenne/ejbql/parser/EJBQLIsEmpty.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLIsNull.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLJoin.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLLength.java | 42 -
.../cayenne/ejbql/parser/EJBQLLessOrEqual.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLLessThan.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLLike.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLLocate.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLLower.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLMax.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLMemberOf.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLMin.java | 46 -
.../org/apache/cayenne/ejbql/parser/EJBQLMod.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLMultiply.java | 42 -
.../ejbql/parser/EJBQLNamedInputParameter.java | 51 -
.../apache/cayenne/ejbql/parser/EJBQLNegative.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLNot.java | 41 -
.../cayenne/ejbql/parser/EJBQLNotEquals.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLOr.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLOrderBy.java | 36 -
.../cayenne/ejbql/parser/EJBQLOrderByItem.java | 36 -
.../cayenne/ejbql/parser/EJBQLOuterFetchJoin.java | 47 -
.../cayenne/ejbql/parser/EJBQLOuterJoin.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLPath.java | 74 --
.../cayenne/ejbql/parser/EJBQLPatternValue.java | 36 -
.../parser/EJBQLPositionalInputParameter.java | 55 -
.../apache/cayenne/ejbql/parser/EJBQLSelect.java | 36 -
.../cayenne/ejbql/parser/EJBQLSelectClause.java | 36 -
.../ejbql/parser/EJBQLSelectExpression.java | 36 -
.../ejbql/parser/EJBQLSelectExpressions.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLSize.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLSqrt.java | 42 -
.../cayenne/ejbql/parser/EJBQLStringLiteral.java | 36 -
.../cayenne/ejbql/parser/EJBQLSubselect.java | 36 -
.../cayenne/ejbql/parser/EJBQLSubstring.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLSubtract.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLSum.java | 70 --
.../org/apache/cayenne/ejbql/parser/EJBQLTok.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLTrim.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLTrimBoth.java | 36 -
.../cayenne/ejbql/parser/EJBQLTrimCharacter.java | 36 -
.../cayenne/ejbql/parser/EJBQLTrimLeading.java | 36 -
.../ejbql/parser/EJBQLTrimSpecification.java | 30 -
.../cayenne/ejbql/parser/EJBQLTrimTrailing.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLUpdate.java | 36 -
.../cayenne/ejbql/parser/EJBQLUpdateField.java | 42 -
.../cayenne/ejbql/parser/EJBQLUpdateItem.java | 42 -
.../cayenne/ejbql/parser/EJBQLUpdateValue.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLUpper.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLWhere.java | 36 -
.../java/org/apache/cayenne/ejbql/parser/Node.java | 61 -
.../apache/cayenne/ejbql/parser/SimpleNode.java | 161 ---
.../java/org/apache/cayenne/exp/AsteriskExp.java | 6 -
.../java/org/apache/cayenne/exp/BitwiseAndExp.java | 5 -
.../apache/cayenne/exp/BitwiseLeftShiftExp.java | 5 -
.../java/org/apache/cayenne/exp/BitwiseNotExp.java | 6 -
.../java/org/apache/cayenne/exp/BitwiseOrExp.java | 6 -
.../apache/cayenne/exp/BitwiseRightShiftExp.java | 6 -
.../java/org/apache/cayenne/exp/BitwiseXorExp.java | 6 -
.../java/org/apache/cayenne/exp/CaseWhenExp.java | 6 -
.../org/apache/cayenne/exp/CustomOperatorExp.java | 6 -
.../java/org/apache/cayenne/exp/DbIdPathExp.java | 9 -
.../java/org/apache/cayenne/exp/DbPathExp.java | 11 -
.../main/java/org/apache/cayenne/exp/ElseExp.java | 8 -
.../main/java/org/apache/cayenne/exp/EnumRef.java | 94 ++
.../main/java/org/apache/cayenne/exp/EqualExp.java | 9 -
.../java/org/apache/cayenne/exp/ExpHelper.java | 71 --
.../java/org/apache/cayenne/exp/Expression.java | 119 --
.../main/java/org/apache/cayenne/exp/FalseExp.java | 6 -
.../org/apache/cayenne/exp/FunctionCallExp.java | 9 -
.../java/org/apache/cayenne/exp/IgnoreCaseExp.java | 20 -
.../org/apache/cayenne/exp/LikeIgnoreCaseExp.java | 5 -
.../main/java/org/apache/cayenne/exp/ListExp.java | 23 -
.../java/org/apache/cayenne/exp/NegateExp.java | 10 -
.../java/org/apache/cayenne/exp/NotEqualExp.java | 9 -
.../main/java/org/apache/cayenne/exp/NotExp.java | 7 -
.../apache/cayenne/exp/NotLikeIgnoreCaseExp.java | 5 -
.../java/org/apache/cayenne/exp/ObjPathExp.java | 8 -
.../org/apache/cayenne/exp/PatternMatchExp.java | 19 -
.../java/org/apache/cayenne/exp/ScalarExp.java | 6 -
.../main/java/org/apache/cayenne/exp/ThenExp.java | 8 -
.../main/java/org/apache/cayenne/exp/TrueExp.java | 6 -
.../main/java/org/apache/cayenne/exp/WhenExp.java | 8 -
.../apache/cayenne/map/EJBQLQueryDescriptor.java | 90 --
.../org/apache/cayenne/map/QueryDescriptor.java | 9 -
.../apache/cayenne/map/QueryDescriptorLoader.java | 11 -
.../apache/cayenne/query/BaseQueryMetadata.java | 1 -
.../java/org/apache/cayenne/query/EJBQLQuery.java | 292 -----
.../apache/cayenne/query/EJBQLQueryMetadata.java | 99 --
.../org/apache/cayenne/query/MappedSelect.java | 21 -
.../org/apache/cayenne/query/PrefetchTreeNode.java | 9 -
.../org/apache/cayenne/query/SQLActionVisitor.java | 5 -
.../reflect/LifecycleCallbackEventHandler.java | 2 +-
.../org/apache/cayenne/ejbql/EJBQLParser.jjt | 1266 --------------------
.../org/apache/cayenne/schema/14/modelMap.xsd | 3 -
.../java/org/apache/cayenne/CayenneCompoundIT.java | 13 -
.../test/java/org/apache/cayenne/CayenneIT.java | 24 -
.../access/DataContextEJBQLArrayResultIT.java | 118 --
.../access/DataContextEJBQLConditionsIT.java | 470 --------
.../access/DataContextEJBQLConditionsPeopleIT.java | 146 ---
...ontextEJBQLDateTimeFunctionalExpressionsIT.java | 117 --
.../cayenne/access/DataContextEJBQLDeleteIT.java | 120 --
.../cayenne/access/DataContextEJBQLDeletePKIT.java | 75 --
.../access/DataContextEJBQLFetchJoinIT.java | 380 ------
.../DataContextEJBQLFlattenedRelationshipsIT.java | 320 -----
.../DataContextEJBQLFunctionalExpressionsIT.java | 271 -----
.../access/DataContextEJBQLGroupByHavingIT.java | 338 ------
.../access/DataContextEJBQLInheritanceIT.java | 78 --
.../cayenne/access/DataContextEJBQLIsNullIT.java | 179 ---
.../cayenne/access/DataContextEJBQLJoinsIT.java | 243 ----
.../DataContextEJBQLNumericalFunctionalIT.java | 143 ---
.../cayenne/access/DataContextEJBQLOrderByIT.java | 218 ----
.../access/DataContextEJBQLQueryCallback.java | 28 -
.../access/DataContextEJBQLQueryCompoundIT.java | 130 --
.../cayenne/access/DataContextEJBQLQueryIT.java | 496 --------
.../cayenne/access/DataContextEJBQLSubqueryIT.java | 238 ----
.../access/DataContextEJBQLUpdateCompoundIT.java | 98 --
.../cayenne/access/DataContextEJBQLUpdateIT.java | 246 ----
.../access/DataContextFlattenedAttributesIT.java | 142 +--
.../org/apache/cayenne/access/DataContextIT.java | 16 -
.../cayenne/access/DataDomainCallbacksIT.java | 4 +-
.../apache/cayenne/access/QuotedIdentifiersIT.java | 38 -
.../cayenne/access/VerticalInheritanceIT.java | 83 --
.../translator/ejbql/EJBQLSelectTranslatorIT.java | 334 ------
.../EJBQLVerticalInheritanceTranslatorIT.java | 96 --
.../upgrade/UpgradeHandler_V14Test.java | 16 +-
.../configuration/xml/XMLDataMapLoaderTest.java | 6 +-
.../java/org/apache/cayenne/dba/AutoAdapterIT.java | 1 -
.../java/org/apache/cayenne/ejbql/EJBQLEnum1.java | 24 -
.../cayenne/ejbql/EJBQLParserFactoryTest.java | 42 -
.../cayenne/ejbql/EJBQLParser_CompileIT.java | 137 ---
.../cayenne/ejbql/EJBQLParser_ParseTest.java | 65 -
.../apache/cayenne/ejbql/parser/EJBQLPathTest.java | 40 -
.../java/org/apache/cayenne/exp/EqualExpTest.java | 21 -
.../org/apache/cayenne/exp/ExpressionTest.java | 163 ---
.../java/org/apache/cayenne/exp/InExpTest.java | 8 -
.../java/org/apache/cayenne/exp/LikeExpTest.java | 10 -
.../apache/cayenne/exp/LikeIgnoreCaseExpTest.java | 7 -
.../org/apache/cayenne/exp/ObjPathExpTest.java | 10 -
.../java/org/apache/cayenne/exp/ScalarExpTest.java | 6 -
.../cayenne/map/EJBQLQueryDescriptorTest.java | 65 -
.../apache/cayenne/query/EJBQLQueryCountIT.java | 105 --
.../org/apache/cayenne/query/EJBQLQueryIT.java | 669 -----------
.../apache/cayenne/query/EJBQLQueryNumericIT.java | 67 --
.../org/apache/cayenne/query/MappedQueryIT.java | 9 -
.../org/apache/cayenne/query/QueryTimeoutIT.java | 10 -
.../cayenne/query/QueryWithCompoundJoinIT.java | 11 -
.../apache/cayenne/query/StatementFetchSizeIT.java | 11 -
cayenne/src/test/resources/multi-tier.map.xml | 4 -
.../configuration/upgrade/v14/cayenne-project1.xml | 2 +
.../cayenne/configuration/upgrade/v14/map1.map.xml | 7 +
.../configuration/xml/testConfigMap4.map.xml | 5 -
cayenne/src/test/resources/testmap.map.xml | 5 -
.../asciidoc/_cayenne-guide/queries/mapped.adoc | 2 +-
pom.xml | 6 -
297 files changed, 198 insertions(+), 21801 deletions(-)
delete mode 100644 cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryMainTab.java
delete mode 100644 cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryPropertiesPanel.java
delete mode 100644 cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryScriptsTab.java
delete mode 100644 cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlSyntax.java
delete mode 100644 cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlTabbedView.java
delete mode 100644 cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLQueryValidator.java
delete mode 100644 cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLStatementValidator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/EJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/DbAdapterDelegatedEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLAggregateColumnTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDbPathTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDeleteTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLFromTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLGroupByTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdColumnsTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdentifierColumnsTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLJoinAppender.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLMultiColumnOperand.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLPathTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectColumnsTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTableId.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTranslationContext.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateItemTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/JdbcEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLSubselectTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLConditionTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLSubselectTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLTranslator.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLCompiledExpression.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLException.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpression.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParser.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParserFactory.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/AggregateConditionNode.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/CompiledExpression.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/Compiler.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAbs.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAbstractSchemaName.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAdd.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAggregate.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAggregateColumn.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAll.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAnd.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAny.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAscending.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLAverage.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLBetween.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLBooleanLiteral.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLClassName.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLConcat.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLConstructor.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLConstructorParameter.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLConstructorParameters.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLCount.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLCurrentDate.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLCurrentTime.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLCurrentTimestamp.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDbPath.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDecimalLiteral.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDelete.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDescending.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDistinct.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDivide.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLEquals.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLEscapeCharacter.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLExists.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLFrom.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLFromItem.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLGreaterOrEqual.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLGreaterThan.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLGroupBy.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLHaving.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLIdentificationVariable.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLIdentifier.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLIn.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLInnerFetchJoin.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLInnerJoin.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLIntegerLiteral.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLIsEmpty.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLIsNull.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLJoin.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLLength.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLLessOrEqual.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLLessThan.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLLike.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLLocate.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLLower.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLMax.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLMemberOf.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLMin.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLMod.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLMultiply.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLNamedInputParameter.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLNegative.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLNot.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLNotEquals.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLOr.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLOrderBy.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLOrderByItem.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLOuterFetchJoin.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLOuterJoin.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLPath.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLPatternValue.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLPositionalInputParameter.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSelect.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSelectClause.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSelectExpression.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSelectExpressions.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSize.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSqrt.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLStringLiteral.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSubselect.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSubstring.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSubtract.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLSum.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLTok.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLTrim.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLTrimBoth.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLTrimCharacter.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLTrimLeading.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLTrimSpecification.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLTrimTrailing.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLUpdate.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLUpdateField.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLUpdateItem.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLUpdateValue.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLUpper.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLWhere.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/Node.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ejbql/parser/SimpleNode.java
create mode 100644 cayenne/src/main/java/org/apache/cayenne/exp/EnumRef.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/map/EJBQLQueryDescriptor.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
delete mode 100644 cayenne/src/main/jjtree/org/apache/cayenne/ejbql/EJBQLParser.jjt
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLArrayResultIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLConditionsIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLConditionsPeopleIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLDateTimeFunctionalExpressionsIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeleteIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeletePKIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLFetchJoinIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLFlattenedRelationshipsIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLFunctionalExpressionsIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLInheritanceIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLIsNullIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLJoinsIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLNumericalFunctionalIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLOrderByIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryCallback.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryCompoundIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateCompoundIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/DataContextEJBQLUpdateIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslatorIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/access/translator/ejbql/EJBQLVerticalInheritanceTranslatorIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/ejbql/EJBQLEnum1.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/ejbql/EJBQLParserFactoryTest.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/ejbql/EJBQLParser_CompileIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/ejbql/EJBQLParser_ParseTest.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/ejbql/parser/EJBQLPathTest.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/map/EJBQLQueryDescriptorTest.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/query/EJBQLQueryCountIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/query/EJBQLQueryIT.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/query/EJBQLQueryNumericIT.java
(cayenne) 02/02: CAY-3038 Remove EJBQLQuery
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 040e3c746be6e864a6f6bf651d73408757efab93
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Mon Sep 28 08:57:31 2026 -0400
CAY-3038 Remove EJBQLQuery
---
.claude/rules/cayenne/architecture.md | 1 -
RELEASE-NOTES.txt | 1 +
UPGRADE.md | 15 +
ai-plugin/references/datamap-schema.md | 8 -
ai-plugin/references/model-naming-rename-safety.md | 6 +-
ai-plugin/skills/cayenne-model-naming/SKILL.md | 6 +-
cayenne-ant/src/test/resources/testmap.map.xml | 5 -
.../org/apache/cayenne/gen/DataMapArtifact.java | 1 -
.../cayenne/dbsync/naming/NameBuilderTest.java | 2 +-
.../src/test/resources/cgen/output/testmap.map.xml | 5 -
.../cayenne/modeler/ui/action/FindAction.java | 2 -
.../cayenne/modeler/ui/action/RemoveAction.java | 9 +-
.../modeler/ui/project/editor/EditorPanelView.java | 12 -
.../editor/query/ejbql/EjbqlQueryMainTab.java | 173 ---
.../query/ejbql/EjbqlQueryPropertiesPanel.java | 65 -
.../editor/query/ejbql/EjbqlQueryScriptsTab.java | 263 ----
.../ui/project/editor/query/ejbql/EjbqlSyntax.java | 67 --
.../editor/query/ejbql/EjbqlTabbedView.java | 87 --
.../ui/project/querytype/QueryTypeDialog.java | 9 +-
.../cayenne/modeler/undo/TextCompoundEdit.java | 5 -
.../validation/DefaultProjectValidator.java | 5 -
.../project/validation/EJBQLQueryValidator.java | 50 -
.../validation/EJBQLStatementValidator.java | 169 ---
.../cayenne/project/validation/Inspection.java | 3 -
.../apache/cayenne/velocity/ResultDirective.java | 6 +-
cayenne/pom.xml | 71 +-
.../java/org/apache/cayenne/access/DataNode.java | 16 -
.../org/apache/cayenne/access/DataRowStore.java | 2 +-
.../org/apache/cayenne/access/ObjectResolver.java | 3 +-
.../apache/cayenne/access/jdbc/EJBQLAction.java | 184 ---
.../jdbc/reader/DefaultRowReaderFactory.java | 4 +-
.../cayenne/access/translator/EJBQLTranslator.java | 56 -
.../ejbql/DbAdapterDelegatedEJBQLTranslator.java | 96 --
.../ejbql/EJBQLAggregateColumnTranslator.java | 192 ---
.../translator/ejbql/EJBQLConditionTranslator.java | 1180 ------------------
.../translator/ejbql/EJBQLDbPathTranslator.java | 286 -----
.../translator/ejbql/EJBQLDeleteTranslator.java | 56 -
.../translator/ejbql/EJBQLFromTranslator.java | 112 --
.../translator/ejbql/EJBQLGroupByTranslator.java | 124 --
.../translator/ejbql/EJBQLIdColumnsTranslator.java | 62 -
.../ejbql/EJBQLIdentifierColumnsTranslator.java | 255 ----
.../access/translator/ejbql/EJBQLJoinAppender.java | 357 ------
.../translator/ejbql/EJBQLMultiColumnOperand.java | 92 --
.../translator/ejbql/EJBQLOrderByTranslator.java | 83 --
.../translator/ejbql/EJBQLPathTranslator.java | 331 -----
.../ejbql/EJBQLSelectColumnsTranslator.java | 244 ----
.../translator/ejbql/EJBQLSelectTranslator.java | 116 --
.../access/translator/ejbql/EJBQLTableId.java | 144 ---
.../translator/ejbql/EJBQLTranslationContext.java | 526 --------
.../ejbql/EJBQLUpdateItemTranslator.java | 124 --
.../translator/ejbql/EJBQLUpdateTranslator.java | 74 --
.../translator/ejbql/JdbcEJBQLTranslator.java | 105 --
.../cayenne/configuration/runtime/CoreModule.java | 3 -
.../runtime/DefaultDataNodeFactory.java | 5 -
.../configuration/upgrade/UpgradeHandler_V14.java | 23 +-
.../configuration/upgrade/UpgradeHandler_V8.java | 2 +-
.../configuration/xml/QueryDescriptorHandler.java | 6 -
.../java/org/apache/cayenne/dba/AutoAdapter.java | 9 -
.../java/org/apache/cayenne/dba/DbAdapter.java | 16 -
.../org/apache/cayenne/dba/JdbcActionBuilder.java | 10 -
.../java/org/apache/cayenne/dba/JdbcAdapter.java | 48 -
.../org/apache/cayenne/dba/db2/DB2Adapter.java | 12 -
.../dba/db2/DB2EJBQLConditionTranslator.java | 54 -
.../apache/cayenne/dba/db2/DB2EJBQLTranslator.java | 37 -
.../org/apache/cayenne/dba/derby/DerbyAdapter.java | 12 -
.../dba/derby/DerbyEJBQLConditionTranslator.java | 55 -
.../cayenne/dba/derby/DerbyEJBQLTranslator.java | 36 -
.../cayenne/dba/firebird/FirebirdAdapter.java | 9 -
.../firebird/FirebirdEJBQLConditionTranslator.java | 105 --
.../dba/firebird/FirebirdEJBQLTranslator.java | 37 -
.../java/org/apache/cayenne/dba/h2/H2Adapter.java | 13 -
.../cayenne/dba/h2/H2EJBQLConditionTranslator.java | 66 -
.../apache/cayenne/dba/h2/H2EJBQLTranslator.java | 35 -
.../apache/cayenne/dba/hsqldb/HSQLDBAdapter.java | 12 -
.../dba/hsqldb/HSQLEJBQLConditionTranslator.java | 65 -
.../cayenne/dba/hsqldb/HSQLEJBQLTranslator.java | 35 -
.../org/apache/cayenne/dba/mysql/MySQLAdapter.java | 12 -
.../dba/mysql/MySQLEJBQLConditionTranslator.java | 94 --
.../cayenne/dba/mysql/MySQLEJBQLTranslator.java | 35 -
.../apache/cayenne/dba/oracle/OracleAdapter.java | 9 -
.../dba/oracle/OracleEJBQLConditionTranslator.java | 97 --
.../cayenne/dba/oracle/OracleEJBQLTranslator.java | 34 -
.../cayenne/dba/sqlserver/SQLServerAdapter.java | 6 -
.../SQLServerEJBQLConditionTranslator.java | 50 -
.../SQLServerEJBQLSubselectTranslator.java | 45 -
.../dba/sqlserver/SQLServerEJBQLTranslator.java | 31 -
.../apache/cayenne/dba/sybase/SybaseAdapter.java | 9 -
.../dba/sybase/SybaseEJBQLConditionTranslator.java | 50 -
.../dba/sybase/SybaseEJBQLSubselectTranslator.java | 45 -
.../cayenne/dba/sybase/SybaseEJBQLTranslator.java | 31 -
.../org/apache/cayenne/ejbql/EJBQLBaseVisitor.java | 409 -------
.../cayenne/ejbql/EJBQLCompiledExpression.java | 72 --
.../org/apache/cayenne/ejbql/EJBQLException.java | 51 -
.../org/apache/cayenne/ejbql/EJBQLExpression.java | 53 -
.../cayenne/ejbql/EJBQLExpressionVisitor.java | 359 ------
.../java/org/apache/cayenne/ejbql/EJBQLParser.java | 41 -
.../apache/cayenne/ejbql/EJBQLParserFactory.java | 53 -
.../ejbql/parser/AggregateConditionNode.java | 42 -
.../cayenne/ejbql/parser/CompiledExpression.java | 113 --
.../org/apache/cayenne/ejbql/parser/Compiler.java | 652 ----------
.../org/apache/cayenne/ejbql/parser/EJBQLAbs.java | 42 -
.../ejbql/parser/EJBQLAbstractSchemaName.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLAdd.java | 42 -
.../cayenne/ejbql/parser/EJBQLAggregate.java | 36 -
.../cayenne/ejbql/parser/EJBQLAggregateColumn.java | 35 -
.../org/apache/cayenne/ejbql/parser/EJBQLAll.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLAnd.java | 47 -
.../org/apache/cayenne/ejbql/parser/EJBQLAny.java | 36 -
.../cayenne/ejbql/parser/EJBQLAscending.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLAverage.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLBetween.java | 42 -
.../cayenne/ejbql/parser/EJBQLBooleanLiteral.java | 36 -
.../cayenne/ejbql/parser/EJBQLClassName.java | 37 -
.../apache/cayenne/ejbql/parser/EJBQLConcat.java | 42 -
.../cayenne/ejbql/parser/EJBQLConstructor.java | 36 -
.../ejbql/parser/EJBQLConstructorParameter.java | 36 -
.../ejbql/parser/EJBQLConstructorParameters.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLCount.java | 46 -
.../cayenne/ejbql/parser/EJBQLCurrentDate.java | 36 -
.../cayenne/ejbql/parser/EJBQLCurrentTime.java | 36 -
.../ejbql/parser/EJBQLCurrentTimestamp.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLDbPath.java | 39 -
.../cayenne/ejbql/parser/EJBQLDecimalLiteral.java | 40 -
.../apache/cayenne/ejbql/parser/EJBQLDelete.java | 36 -
.../cayenne/ejbql/parser/EJBQLDescending.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLDistinct.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLDivide.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLEquals.java | 42 -
.../cayenne/ejbql/parser/EJBQLEscapeCharacter.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLExists.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLFrom.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLFromItem.java | 96 --
.../cayenne/ejbql/parser/EJBQLGreaterOrEqual.java | 42 -
.../cayenne/ejbql/parser/EJBQLGreaterThan.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLGroupBy.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLHaving.java | 36 -
.../ejbql/parser/EJBQLIdentificationVariable.java | 36 -
.../cayenne/ejbql/parser/EJBQLIdentifier.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLIn.java | 42 -
.../cayenne/ejbql/parser/EJBQLInnerFetchJoin.java | 47 -
.../cayenne/ejbql/parser/EJBQLInnerJoin.java | 36 -
.../cayenne/ejbql/parser/EJBQLIntegerLiteral.java | 40 -
.../apache/cayenne/ejbql/parser/EJBQLIsEmpty.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLIsNull.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLJoin.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLLength.java | 42 -
.../cayenne/ejbql/parser/EJBQLLessOrEqual.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLLessThan.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLLike.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLLocate.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLLower.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLMax.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLMemberOf.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLMin.java | 46 -
.../org/apache/cayenne/ejbql/parser/EJBQLMod.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLMultiply.java | 42 -
.../ejbql/parser/EJBQLNamedInputParameter.java | 51 -
.../apache/cayenne/ejbql/parser/EJBQLNegative.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLNot.java | 41 -
.../cayenne/ejbql/parser/EJBQLNotEquals.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLOr.java | 46 -
.../apache/cayenne/ejbql/parser/EJBQLOrderBy.java | 36 -
.../cayenne/ejbql/parser/EJBQLOrderByItem.java | 36 -
.../cayenne/ejbql/parser/EJBQLOuterFetchJoin.java | 47 -
.../cayenne/ejbql/parser/EJBQLOuterJoin.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLPath.java | 74 --
.../cayenne/ejbql/parser/EJBQLPatternValue.java | 36 -
.../parser/EJBQLPositionalInputParameter.java | 55 -
.../apache/cayenne/ejbql/parser/EJBQLSelect.java | 36 -
.../cayenne/ejbql/parser/EJBQLSelectClause.java | 36 -
.../ejbql/parser/EJBQLSelectExpression.java | 36 -
.../ejbql/parser/EJBQLSelectExpressions.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLSize.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLSqrt.java | 42 -
.../cayenne/ejbql/parser/EJBQLStringLiteral.java | 36 -
.../cayenne/ejbql/parser/EJBQLSubselect.java | 36 -
.../cayenne/ejbql/parser/EJBQLSubstring.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLSubtract.java | 42 -
.../org/apache/cayenne/ejbql/parser/EJBQLSum.java | 70 --
.../org/apache/cayenne/ejbql/parser/EJBQLTok.java | 36 -
.../org/apache/cayenne/ejbql/parser/EJBQLTrim.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLTrimBoth.java | 36 -
.../cayenne/ejbql/parser/EJBQLTrimCharacter.java | 36 -
.../cayenne/ejbql/parser/EJBQLTrimLeading.java | 36 -
.../ejbql/parser/EJBQLTrimSpecification.java | 30 -
.../cayenne/ejbql/parser/EJBQLTrimTrailing.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLUpdate.java | 36 -
.../cayenne/ejbql/parser/EJBQLUpdateField.java | 42 -
.../cayenne/ejbql/parser/EJBQLUpdateItem.java | 42 -
.../cayenne/ejbql/parser/EJBQLUpdateValue.java | 36 -
.../apache/cayenne/ejbql/parser/EJBQLUpper.java | 42 -
.../apache/cayenne/ejbql/parser/EJBQLWhere.java | 36 -
.../java/org/apache/cayenne/ejbql/parser/Node.java | 61 -
.../apache/cayenne/ejbql/parser/SimpleNode.java | 161 ---
.../java/org/apache/cayenne/exp/AsteriskExp.java | 6 -
.../java/org/apache/cayenne/exp/BitwiseAndExp.java | 5 -
.../apache/cayenne/exp/BitwiseLeftShiftExp.java | 5 -
.../java/org/apache/cayenne/exp/BitwiseNotExp.java | 6 -
.../java/org/apache/cayenne/exp/BitwiseOrExp.java | 6 -
.../apache/cayenne/exp/BitwiseRightShiftExp.java | 6 -
.../java/org/apache/cayenne/exp/BitwiseXorExp.java | 6 -
.../java/org/apache/cayenne/exp/CaseWhenExp.java | 6 -
.../org/apache/cayenne/exp/CustomOperatorExp.java | 6 -
.../java/org/apache/cayenne/exp/DbIdPathExp.java | 9 -
.../java/org/apache/cayenne/exp/DbPathExp.java | 11 -
.../main/java/org/apache/cayenne/exp/ElseExp.java | 8 -
.../main/java/org/apache/cayenne/exp/EqualExp.java | 9 -
.../java/org/apache/cayenne/exp/ExpHelper.java | 71 --
.../java/org/apache/cayenne/exp/Expression.java | 119 --
.../main/java/org/apache/cayenne/exp/FalseExp.java | 6 -
.../org/apache/cayenne/exp/FunctionCallExp.java | 9 -
.../java/org/apache/cayenne/exp/IgnoreCaseExp.java | 20 -
.../org/apache/cayenne/exp/LikeIgnoreCaseExp.java | 5 -
.../main/java/org/apache/cayenne/exp/ListExp.java | 23 -
.../java/org/apache/cayenne/exp/NegateExp.java | 10 -
.../java/org/apache/cayenne/exp/NotEqualExp.java | 9 -
.../main/java/org/apache/cayenne/exp/NotExp.java | 7 -
.../apache/cayenne/exp/NotLikeIgnoreCaseExp.java | 5 -
.../java/org/apache/cayenne/exp/ObjPathExp.java | 8 -
.../org/apache/cayenne/exp/PatternMatchExp.java | 19 -
.../java/org/apache/cayenne/exp/ScalarExp.java | 6 -
.../main/java/org/apache/cayenne/exp/ThenExp.java | 8 -
.../main/java/org/apache/cayenne/exp/TrueExp.java | 6 -
.../main/java/org/apache/cayenne/exp/WhenExp.java | 8 -
.../apache/cayenne/map/EJBQLQueryDescriptor.java | 90 --
.../org/apache/cayenne/map/QueryDescriptor.java | 9 -
.../apache/cayenne/map/QueryDescriptorLoader.java | 11 -
.../apache/cayenne/query/BaseQueryMetadata.java | 1 -
.../java/org/apache/cayenne/query/EJBQLQuery.java | 292 -----
.../apache/cayenne/query/EJBQLQueryMetadata.java | 99 --
.../org/apache/cayenne/query/MappedSelect.java | 21 -
.../org/apache/cayenne/query/PrefetchTreeNode.java | 9 -
.../org/apache/cayenne/query/SQLActionVisitor.java | 5 -
.../reflect/LifecycleCallbackEventHandler.java | 2 +-
.../org/apache/cayenne/ejbql/EJBQLParser.jjt | 1266 --------------------
.../org/apache/cayenne/schema/14/modelMap.xsd | 3 -
.../java/org/apache/cayenne/CayenneCompoundIT.java | 13 -
.../test/java/org/apache/cayenne/CayenneIT.java | 24 -
.../access/DataContextEJBQLArrayResultIT.java | 118 --
.../access/DataContextEJBQLConditionsIT.java | 470 --------
.../access/DataContextEJBQLConditionsPeopleIT.java | 146 ---
...ontextEJBQLDateTimeFunctionalExpressionsIT.java | 117 --
.../cayenne/access/DataContextEJBQLDeleteIT.java | 120 --
.../cayenne/access/DataContextEJBQLDeletePKIT.java | 75 --
.../access/DataContextEJBQLFetchJoinIT.java | 380 ------
.../DataContextEJBQLFlattenedRelationshipsIT.java | 320 -----
.../DataContextEJBQLFunctionalExpressionsIT.java | 271 -----
.../access/DataContextEJBQLGroupByHavingIT.java | 338 ------
.../access/DataContextEJBQLInheritanceIT.java | 78 --
.../cayenne/access/DataContextEJBQLIsNullIT.java | 179 ---
.../cayenne/access/DataContextEJBQLJoinsIT.java | 243 ----
.../DataContextEJBQLNumericalFunctionalIT.java | 143 ---
.../cayenne/access/DataContextEJBQLOrderByIT.java | 218 ----
.../access/DataContextEJBQLQueryCallback.java | 28 -
.../access/DataContextEJBQLQueryCompoundIT.java | 130 --
.../cayenne/access/DataContextEJBQLQueryIT.java | 496 --------
.../cayenne/access/DataContextEJBQLSubqueryIT.java | 238 ----
.../access/DataContextEJBQLUpdateCompoundIT.java | 98 --
.../cayenne/access/DataContextEJBQLUpdateIT.java | 246 ----
.../access/DataContextFlattenedAttributesIT.java | 142 +--
.../org/apache/cayenne/access/DataContextIT.java | 16 -
.../cayenne/access/DataDomainCallbacksIT.java | 4 +-
.../apache/cayenne/access/QuotedIdentifiersIT.java | 38 -
.../cayenne/access/VerticalInheritanceIT.java | 83 --
.../translator/ejbql/EJBQLSelectTranslatorIT.java | 334 ------
.../EJBQLVerticalInheritanceTranslatorIT.java | 96 --
.../upgrade/UpgradeHandler_V14Test.java | 16 +-
.../configuration/xml/XMLDataMapLoaderTest.java | 6 +-
.../java/org/apache/cayenne/dba/AutoAdapterIT.java | 1 -
.../java/org/apache/cayenne/ejbql/EJBQLEnum1.java | 24 -
.../cayenne/ejbql/EJBQLParserFactoryTest.java | 42 -
.../cayenne/ejbql/EJBQLParser_CompileIT.java | 137 ---
.../cayenne/ejbql/EJBQLParser_ParseTest.java | 65 -
.../apache/cayenne/ejbql/parser/EJBQLPathTest.java | 40 -
.../java/org/apache/cayenne/exp/EqualExpTest.java | 21 -
.../org/apache/cayenne/exp/ExpressionTest.java | 163 ---
.../java/org/apache/cayenne/exp/InExpTest.java | 8 -
.../java/org/apache/cayenne/exp/LikeExpTest.java | 10 -
.../apache/cayenne/exp/LikeIgnoreCaseExpTest.java | 7 -
.../org/apache/cayenne/exp/ObjPathExpTest.java | 10 -
.../java/org/apache/cayenne/exp/ScalarExpTest.java | 6 -
.../cayenne/map/EJBQLQueryDescriptorTest.java | 65 -
.../apache/cayenne/query/EJBQLQueryCountIT.java | 105 --
.../org/apache/cayenne/query/EJBQLQueryIT.java | 669 -----------
.../apache/cayenne/query/EJBQLQueryNumericIT.java | 67 --
.../org/apache/cayenne/query/MappedQueryIT.java | 9 -
.../org/apache/cayenne/query/QueryTimeoutIT.java | 10 -
.../cayenne/query/QueryWithCompoundJoinIT.java | 11 -
.../apache/cayenne/query/StatementFetchSizeIT.java | 11 -
cayenne/src/test/resources/multi-tier.map.xml | 4 -
.../configuration/upgrade/v14/cayenne-project1.xml | 2 +
.../cayenne/configuration/upgrade/v14/map1.map.xml | 7 +
.../configuration/xml/testConfigMap4.map.xml | 5 -
cayenne/src/test/resources/testmap.map.xml | 5 -
.../asciidoc/_cayenne-guide/queries/mapped.adoc | 2 +-
pom.xml | 6 -
296 files changed, 104 insertions(+), 21801 deletions(-)
diff --git a/.claude/rules/cayenne/architecture.md b/.claude/rules/cayenne/architecture.md
index 54a6893cd..7fd691a27 100644
--- a/.claude/rules/cayenne/architecture.md
+++ b/.claude/rules/cayenne/architecture.md
@@ -18,7 +18,6 @@ description: cayenne core module architecture, conventions, and test infrastruct
- **`ObjectSelect`** — Modern fluent API for fetching persistent objects (preferred)
- **`SQLSelect`** / **`SQLExec`** — Raw SQL with Cayenne parameter binding
-- **`EJBQLQuery`** — Legacy EJBQL support
- **`Expression`** / **`ExpressionFactory`** — In-memory and SQL predicate building
### ORM Mapping
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index c5443f7b4..a0726261c 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -39,6 +39,7 @@ CAY-3034 Remove "cayenne-osgi" module
CAY-3035 Remove "cayenne-lifecycle" module
CAY-3036 Auto-upgrade projects in runtime
CAY-3037 Switch ObjectSelect query format in XML to the parsable string
+CAY-3038 Remove EJBQLQuery
CAY-3039 Refactor Expressions to be independent from the parser syntax
Bug Fixes:
diff --git a/UPGRADE.md b/UPGRADE.md
index 7da0db16a..9fb2669b5 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -363,6 +363,21 @@ List<Artist> withExpensivePaintings = ObjectSelect
`SelectQuery` in a DataMap is now stored as a single query String in the syntax of `ObjectSelect.parse(..)`, instead
of the root attributes and the separate `qualifier`, `ordering` and `prefetch` elements. Projects are upgraded
automatically, either in memory by the runtime, or permanently by CayenneModeler.
+* Per [CAY-3038](https://issues.apache.org/jira/browse/CAY-3038) `EJBQLQuery` was removed. The replacement is `ObjectSelect` / `ColumnSelect` parsed from a String
+ (see "Queries Parsed from Strings" above). As there is no automatic conversion of EJBQL to the new query language,
+ an `EJBQLQuery` stored in a DataMap is dropped by the upgrade to project version 14 with a warning, and must be
+ recreated as an `ObjectSelect`:
+
+ ```java
+ // before
+ EJBQLQuery query = new EJBQLQuery("select a from Artist a where a.artistName like :name");
+ query.setParameter("name", "P%");
+ List<Artist> artists = context.performQuery(query);
+
+ // after
+ List<Artist> artists = ObjectSelect.parse(Artist.class, "from Artist where artistName like $name", "P%")
+ .select(context);
+ ```
* Per [CAY-3039](https://issues.apache.org/jira/browse/CAY-3039) the expression node classes are no longer tied to
the parser. They moved from `org.apache.cayenne.exp.parser` to `org.apache.cayenne.exp` and lost the `AST` prefix:
diff --git a/ai-plugin/references/datamap-schema.md b/ai-plugin/references/datamap-schema.md
index 25ba5e3c6..4738b3d1d 100644
--- a/ai-plugin/references/datamap-schema.md
+++ b/ai-plugin/references/datamap-schema.md
@@ -225,14 +225,6 @@ mapped query.
Use a second `<sql>` with `adapter-class=` to vary by DB adapter. SQLTemplate placeholders use Velocity syntax — `#bind($paramName)` for parameters.
-### EJBQLQuery
-
-```xml
-<query name="ArtistByName" type="EJBQLQuery">
- <ejbql><![CDATA[select a from Artist a where a.artistName = ?1]]></ejbql>
-</query>
-```
-
### ProcedureQuery
```xml
diff --git a/ai-plugin/references/model-naming-rename-safety.md b/ai-plugin/references/model-naming-rename-safety.md
index d82cf4111..9806df4d3 100644
--- a/ai-plugin/references/model-naming-rename-safety.md
+++ b/ai-plugin/references/model-naming-rename-safety.md
@@ -44,9 +44,8 @@ For every rename, walk the checklist for that element type. Element shapes are i
| `className` simple name | Same `<obj-entity>`. Keep it equal to the new `name` → the generated class is `Y`. Old `X.java` / `_X.java` become orphaned; regenerate and delete the stale pair. |
| `source="X"` / `target="X"` | Every `<obj-relationship>` in the DataMap — on **any** entity, not just this one. |
| `root-name="X"` | Every `<query>` with `root="obj-entity"`. |
-| entity name in EJBQL | `<ejbql>` bodies (`select a from X a` → `... from Y a`). |
| `result-entity="X"` | `<query type="ProcedureQuery">`. |
-| Java | `ObjectSelect.query(X.class)` tracks `className`, so updating `className` + regenerating covers it. Also fix string-based entity lookups (`context.newObject("X")`, `objectSelect("X")`) and EJBQL strings in code. |
+| Java | `ObjectSelect.query(X.class)` tracks `className`, so updating `className` + regenerating covers it. Also fix string-based entity lookups (`context.newObject("X")`, `objectSelect("X")`). |
The `dbEntityName` does **not** change — the DbEntity keeps its DB-derived name.
@@ -55,7 +54,6 @@ The `dbEntityName` does **not** change — the DbEntity keeps its DB-derived nam
| Update | Where |
|---|---|
| query qualifiers / orderings | `<qualifier>` and `<ordering>` bodies that reference the old property name. |
-| EJBQL | `<ejbql>` paths (`a.oldName` → `a.newName`). |
| Java | Generated getter/setter changes; fix `Expression`/`Property` paths and `ObjectSelect` column refs in user code. |
`db-attribute-path` is **unaffected** — it names the DB column, which didn't change. Uniqueness is
@@ -66,7 +64,7 @@ within the owning ObjEntity (attrs + rels).
| Update | Where |
|---|---|
| prefetches | `<prefetch>` bodies and any dotted path that traverses this relationship. |
-| qualifiers / orderings / EJBQL | Expression paths that step through the old relationship name. |
+| qualifiers / orderings | Expression paths that step through the old relationship name. |
| Java | Generated getter/setter changes; fix prefetch/expression paths in user code. |
`db-relationship-path` is **unaffected** — it names DbRelationships, not this ObjRelationship's own
diff --git a/ai-plugin/skills/cayenne-model-naming/SKILL.md b/ai-plugin/skills/cayenne-model-naming/SKILL.md
index fb26687d9..fac4e3bcd 100644
--- a/ai-plugin/skills/cayenne-model-naming/SKILL.md
+++ b/ai-plugin/skills/cayenne-model-naming/SKILL.md
@@ -128,10 +128,10 @@ If there are many domain abbreviations to expand, ask the user for a glossary ra
Edit the `*.map.xml`. For **every** rename, walk the matching checklist in
`model-naming-rename-safety.md` and update all references in the same edit:
-- ObjEntity → `className`, every `obj-relationship` `source`/`target`, query `root-name`, EJBQL,
+- ObjEntity → `className`, every `obj-relationship` `source`/`target`, query `root-name`,
`result-entity`.
-- ObjRelationship → prefetch/expression/EJBQL paths (its `db-relationship-path` is unaffected).
-- ObjAttribute → qualifier/ordering/EJBQL paths (its `db-attribute-path` is unaffected).
+- ObjRelationship → prefetch/expression paths (its `db-relationship-path` is unaffected).
+- ObjAttribute → qualifier/ordering paths (its `db-attribute-path` is unaffected).
- DbRelationship → every `db-relationship-path` segment that names it, including inside dotted
flattened chains. This holds whether or not the DbRelationship backs an ObjRelationship — a
standalone DbRelationship can still be named as a segment in another entity's flattened path.
diff --git a/cayenne-ant/src/test/resources/testmap.map.xml b/cayenne-ant/src/test/resources/testmap.map.xml
index 20b0e15e7..731f43bbc 100644
--- a/cayenne-ant/src/test/resources/testmap.map.xml
+++ b/cayenne-ant/src/test/resources/testmap.map.xml
@@ -658,11 +658,6 @@
<obj-relationship name="painting" source="PaintingInfo" target="Painting" deleteRule="Nullify" db-relationship-path="painting"/>
<obj-relationship name="paintingArray" source="ROArtist" target="Painting" deleteRule="Deny" db-relationship-path="paintingArray"/>
<obj-relationship name="toArtist" source="ROPainting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
- <query name="EjbqlQueryTest" type="EJBQLQuery">
- <property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
- <property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
- <ejbql><![CDATA[select a from Artist a]]></ejbql>
- </query>
<query name="NonSelectingQuery" type="SQLTemplate" root="data-map" root-name="testmap">
<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
<sql><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE)
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
index 119b18bd6..2a17ceeab 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
@@ -100,7 +100,6 @@ public class DataMapArtifact implements Artifact {
// Some additional flag could be introduced to control this explicitly.
case QueryDescriptor.PROCEDURE_QUERY:
case QueryDescriptor.SQL_TEMPLATE:
- case QueryDescriptor.EJBQL_QUERY:
execQueries.add(query);
break;
}
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/NameBuilderTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/NameBuilderTest.java
index 06b1566c6..870333d8f 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/NameBuilderTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/NameBuilderTest.java
@@ -108,7 +108,7 @@ public class NameBuilderTest {
assertEquals("query", q0.getName());
map.addQueryDescriptor(q0);
- QueryDescriptor q1 = QueryDescriptor.ejbqlQueryDescriptor();
+ QueryDescriptor q1 = QueryDescriptor.sqlTemplateDescriptor();
q1.setName(NameBuilder.of(q1, map).build());
assertEquals("query1", q1.getName());
map.addQueryDescriptor(q1);
diff --git a/cayenne-maven-plugin/src/test/resources/cgen/output/testmap.map.xml b/cayenne-maven-plugin/src/test/resources/cgen/output/testmap.map.xml
index 20b0e15e7..731f43bbc 100644
--- a/cayenne-maven-plugin/src/test/resources/cgen/output/testmap.map.xml
+++ b/cayenne-maven-plugin/src/test/resources/cgen/output/testmap.map.xml
@@ -658,11 +658,6 @@
<obj-relationship name="painting" source="PaintingInfo" target="Painting" deleteRule="Nullify" db-relationship-path="painting"/>
<obj-relationship name="paintingArray" source="ROArtist" target="Painting" deleteRule="Deny" db-relationship-path="paintingArray"/>
<obj-relationship name="toArtist" source="ROPainting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
- <query name="EjbqlQueryTest" type="EJBQLQuery">
- <property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
- <property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
- <ejbql><![CDATA[select a from Artist a]]></ejbql>
- </query>
<query name="NonSelectingQuery" type="SQLTemplate" root="data-map" root-name="testmap">
<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
<sql><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE)
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/FindAction.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/FindAction.java
index 0003a16b4..c7b6e21e5 100755
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/FindAction.java
+++ b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/FindAction.java
@@ -26,7 +26,6 @@ import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.map.DbAttribute;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.EJBQLQueryDescriptor;
import org.apache.cayenne.map.Embeddable;
import org.apache.cayenne.map.EmbeddableAttribute;
import org.apache.cayenne.map.Entity;
@@ -90,7 +89,6 @@ public class FindAction extends AppAction {
PRIORITY_BY_TYPE.put(DbRelationshipDetected.class, 8); // this one comes from db reverse engineering
PRIORITY_BY_TYPE.put(QueryDescriptor.class, 9);
PRIORITY_BY_TYPE.put(SelectQueryDescriptor.class, 10);
- PRIORITY_BY_TYPE.put(EJBQLQueryDescriptor.class, 11);
PRIORITY_BY_TYPE.put(SQLTemplateDescriptor.class, 12);
PRIORITY_BY_TYPE.put(ProcedureQueryDescriptor.class, 13);
PRIORITY_BY_TYPE.put(Embeddable.class, 14);
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/RemoveAction.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/RemoveAction.java
index 945510b35..9ce9ac9c4 100644
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/RemoveAction.java
+++ b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/action/RemoveAction.java
@@ -385,12 +385,9 @@ ObjRelationshipEvent e = ObjRelationshipEvent.ofRemove(app.getFrame(), rel, enti
// clone to be able to remove within iterator...
for (QueryDescriptor query : new ArrayList<>(map.getQueryDescriptors())) {
- if (!QueryDescriptor.EJBQL_QUERY.equals(query.getType())) {
- Object root = query.getRoot();
-
- if (root == entity || (root instanceof String && root.toString().equals(entity.getName()))) {
- removeQuery(map, query);
- }
+ Object root = query.getRoot();
+ if (root == entity || (root instanceof String && root.toString().equals(entity.getName()))) {
+ removeQuery(map, query);
}
}
}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/EditorPanelView.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/EditorPanelView.java
index acfb438f9..e038adef0 100644
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/EditorPanelView.java
+++ b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/EditorPanelView.java
@@ -30,7 +30,6 @@ import org.apache.cayenne.modeler.ui.project.editor.embeddable.EmbeddableView;
import org.apache.cayenne.modeler.ui.project.editor.objentity.ObjEntityView;
import org.apache.cayenne.modeler.ui.project.editor.procedure.ProcedureQueryTabbedView;
import org.apache.cayenne.modeler.ui.project.editor.procedure.ProcedureTabbedView;
-import org.apache.cayenne.modeler.ui.project.editor.query.ejbql.EjbqlTabbedView;
import org.apache.cayenne.modeler.ui.project.editor.query.selectquery.SelectQueryTabbedView;
import org.apache.cayenne.modeler.ui.project.editor.query.sqltemplate.SQLTemplateTabbedView;
@@ -52,7 +51,6 @@ public class EditorPanelView extends ProjectPanel {
private static final String SELECT_QUERY_VIEW = "SelectQueryView";
private static final String SQL_TEMPLATE_VIEW = "SQLTemplateView";
private static final String PROCEDURE_QUERY_VIEW = "ProcedureQueryView";
- private static final String EJBQL_QUERY_VIEW = "EjbqlQueryView";
private final CardLayout detailLayout;
@@ -63,7 +61,6 @@ public class EditorPanelView extends ProjectPanel {
private final DataMapView dataMapView;
private final ProcedureTabbedView procedureView;
private final SQLTemplateTabbedView sqlTemplateView;
- private final EjbqlTabbedView ejbqlQueryView;
public EditorPanelView(ProjectSession session) {
super(session);
@@ -73,7 +70,6 @@ public class EditorPanelView extends ProjectPanel {
this.dataMapView = new DataMapView(session);
this.procedureView = new ProcedureTabbedView(session);
this.sqlTemplateView = new SQLTemplateTabbedView(session);
- this.ejbqlQueryView = new EjbqlTabbedView(session);
this.embeddableView = new EmbeddableView(session);
this.objDetailView = new ObjEntityView(session);
this.dbDetailView = new DbEntityView(session);
@@ -95,7 +91,6 @@ public class EditorPanelView extends ProjectPanel {
add(new SelectQueryTabbedView(session), SELECT_QUERY_VIEW);
add(sqlTemplateView, SQL_TEMPLATE_VIEW);
add(new ProcedureQueryTabbedView(session), PROCEDURE_QUERY_VIEW);
- add(ejbqlQueryView, EJBQL_QUERY_VIEW);
add(embeddableView, EMBEDDABLE_VIEW);
add(objDetailView, OBJ_VIEW);
add(dbDetailView, DB_VIEW);
@@ -116,10 +111,6 @@ public class EditorPanelView extends ProjectPanel {
return sqlTemplateView;
}
- public EjbqlTabbedView getEjbqlQueryView() {
- return ejbqlQueryView;
- }
-
public ProcedureTabbedView getProcedureView() {
return procedureView;
}
@@ -157,9 +148,6 @@ public class EditorPanelView extends ProjectPanel {
case QueryDescriptor.PROCEDURE_QUERY:
detailLayout.show(this, PROCEDURE_QUERY_VIEW);
break;
- case QueryDescriptor.EJBQL_QUERY:
- detailLayout.show(this, EJBQL_QUERY_VIEW);
- break;
default:
detailLayout.show(this, EMPTY_VIEW);
}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryMainTab.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryMainTab.java
deleted file mode 100644
index d9c88b99f..000000000
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryMainTab.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.modeler.ui.project.editor.query.ejbql;
-
-import com.jgoodies.forms.builder.PanelBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-import com.jgoodies.forms.layout.FormLayout;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.MappingNamespace;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.modeler.event.model.QueryEvent;
-import org.apache.cayenne.modeler.toolkit.text.CMUndoableTextField;
-import org.apache.cayenne.modeler.toolkit.ProjectPanel;
-import org.apache.cayenne.modeler.project.ProjectSession;
-import org.apache.cayenne.modeler.ui.project.editor.EditorForm;
-import org.apache.cayenne.project.extension.info.ObjectInfo;
-import java.util.Objects;
-import org.apache.cayenne.validation.ValidationException;
-
-import javax.swing.JPanel;
-import java.awt.BorderLayout;
-
-
-public class EjbqlQueryMainTab extends ProjectPanel {
-
- protected CMUndoableTextField name;
- protected CMUndoableTextField comment;
- protected EjbqlQueryPropertiesPanel properties;
-
- public EjbqlQueryMainTab(ProjectSession session) {
- super(session);
- initView();
- }
-
- private void initView() {
- // create widgets
- name = new CMUndoableTextField(app.getUndoManager());
- name.addCommitListener(this::setQueryName);
-
- comment = new CMUndoableTextField(app.getUndoManager());
- comment.addCommitListener(this::setQueryComment);
-
- properties = new EjbqlQueryPropertiesPanel(session);
- // assemble
- CellConstraints cc = new CellConstraints();
- FormLayout layout = new FormLayout(
- EditorForm.LABEL_COLUMN + ", $lcgap, fill:max(200dlu;pref)",
- "p");
- PanelBuilder builder = new PanelBuilder(layout);
- builder.setBorder(EditorForm.formBorder());
- builder.addLabel("Name:", cc.xy(1, 1));
- builder.add(name, cc.xy(3, 1));
-
- // the comment closes the form, below the query properties
- PanelBuilder commentBuilder = new PanelBuilder(
- new FormLayout(EditorForm.LABEL_COLUMN + ", $lcgap, fill:max(200dlu;pref)", "p"));
- commentBuilder.setBorder(EditorForm.lastSectionBorder());
- commentBuilder.addLabel("Comment:", cc.xy(1, 1));
- commentBuilder.add(comment, cc.xy(3, 1));
-
- JPanel propertiesAndComment = new JPanel(new BorderLayout());
- propertiesAndComment.add(properties, BorderLayout.NORTH);
- propertiesAndComment.add(commentBuilder.getPanel(), BorderLayout.CENTER);
-
- JPanel sections = new JPanel(new BorderLayout());
- sections.add(builder.getPanel(), BorderLayout.NORTH);
- sections.add(propertiesAndComment, BorderLayout.CENTER);
-
- // no toolbar in this editor, but its form should still start where the other editors' forms do
- this.setLayout(new BorderLayout());
- this.add(EditorForm.toolBarSpacer(), BorderLayout.NORTH);
- this.add(sections, BorderLayout.CENTER);
- }
-
- /**
- * Updates the view from the current model state. Invoked when a currently displayed
- * query is changed.
- */
- void initFromModel() {
- QueryDescriptor query = session.getSelectedQuery();
-
- if (query == null || !QueryDescriptor.EJBQL_QUERY.equals(query.getType())) {
- setVisible(false);
- return;
- }
-
- name.setText(query.getName());
- comment.setText(getQueryComment(query));
- properties.initFromModel(query);
- setVisible(true);
- }
-
- protected QueryDescriptor getQuery() {
- QueryDescriptor query = session.getSelectedQuery();
- return (query != null && QueryDescriptor.EJBQL_QUERY.equals(query.getType())) ? query : null;
- }
-
- /**
- * Initializes Query name from string.
- */
- void setQueryName(String newName) {
- if (newName != null && newName.trim().length() == 0) {
- newName = null;
- }
-
- QueryDescriptor query = getQuery();
-
- if (query == null) {
- return;
- }
-
- if (Objects.equals(newName, query.getName())) {
- return;
- }
-
- if (newName == null) {
- throw new ValidationException("Query name is required.");
- }
-
- DataMap map = session.getSelectedDataMap();
-
- if (map.getQueryDescriptor(newName) == null) {
- // completely new name, set new name for entity
- String oldName = query.getName();
- QueryEvent e = QueryEvent.ofChange(this, query, oldName);
- query.setName(newName);
- query.setDataMap(map);
- map.removeQueryDescriptor(oldName);
- map.addQueryDescriptor(query);
- MappingNamespace ns = map.getNamespace();
- if (ns instanceof EntityResolver) {
- ((EntityResolver) ns).refreshMappingCache();
- }
- session.fireQueryEvent(e);
- }
- else {
- // there is a query with the same name
- throw new ValidationException("There is another query named '"
- + newName
- + "'. Use a different name.");
- }
- }
-
- private void setQueryComment(String text) {
- QueryDescriptor query = getQuery();
- if (query == null) {
- return;
- }
- ObjectInfo.putToMetaData(app.getMetaData(), query, ObjectInfo.COMMENT, text);
- session.fireQueryEvent(QueryEvent.ofChange(this, query));
- }
-
- private String getQueryComment(QueryDescriptor queryDescriptor) {
- return ObjectInfo.getFromMetaData(app.getMetaData(), queryDescriptor, ObjectInfo.COMMENT);
- }
-}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryPropertiesPanel.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryPropertiesPanel.java
deleted file mode 100644
index a91f5ce79..000000000
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryPropertiesPanel.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.modeler.ui.project.editor.query.ejbql;
-
-import org.apache.cayenne.modeler.ui.project.editor.EditorForm;
-import org.apache.cayenne.modeler.ui.project.editor.query.SelectPropertiesPanel;
-
-import java.awt.BorderLayout;
-
-import org.apache.cayenne.modeler.project.ProjectSession;
-
-import com.jgoodies.forms.builder.PanelBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-import com.jgoodies.forms.layout.FormLayout;
-
-public class EjbqlQueryPropertiesPanel extends SelectPropertiesPanel {
-
- public EjbqlQueryPropertiesPanel(ProjectSession session) {
- super(session);
- }
-
- protected PanelBuilder createPanelBuilder() {
- CellConstraints cc = new CellConstraints();
- FormLayout layout = new FormLayout(
- EditorForm.LABEL_COLUMN + ", $lcgap, left:max(10dlu;pref), "
- + "$lcgap, left:max(37dlu;pref), $lcgap, fill:max(147dlu;pref)",
- "p, $rgap, p, $rgap, p, $rgap, p, $rgap, p");
-
- PanelBuilder builder = new PanelBuilder(layout);
- builder.setBorder(EditorForm.sectionBorder());
- builder.addLabel("Result Caching:", cc.xy(1, 1));
- builder.add(cacheStrategy, cc.xywh(3, 1, 5, 1));
- cacheGroupsLabel = builder.addLabel("Cache Group:", cc.xy(1, 3));
- builder.add(cacheGroups, cc.xywh(3, 3, 5, 1));
- builder.addLabel("Fetch Offset, Rows:", cc.xy(1, 5));
- builder.add(fetchOffset, cc.xywh(3, 5, 3, 1));
- builder.addLabel("Fetch Limit, Rows:", cc.xy(1, 7));
- builder.add(fetchLimit, cc.xywh(3, 7, 3, 1));
- builder.addLabel("Page Size:", cc.xy(1, 9));
- builder.add(pageSize, cc.xywh(3, 9, 3, 1));
- return builder;
- }
-
- protected void initView() {
- super.initView();
- this.setLayout(new BorderLayout());
- this.add(createPanelBuilder().getPanel(), BorderLayout.CENTER);
- }
-}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryScriptsTab.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryScriptsTab.java
deleted file mode 100644
index c9a687f8b..000000000
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlQueryScriptsTab.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.modeler.ui.project.editor.query.ejbql;
-
-import java.awt.BorderLayout;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-
-import javax.swing.SwingUtilities;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-
-import org.apache.cayenne.modeler.event.model.QueryEvent;
-import org.apache.cayenne.modeler.toolkit.ProjectPanel;
-import org.apache.cayenne.modeler.project.ProjectSession;
-import org.apache.cayenne.modeler.toolkit.text.CMUndoableTextPane;
-import org.apache.cayenne.project.validation.EJBQLStatementValidator;
-import org.apache.cayenne.project.validation.EJBQLStatementValidator.PositionException;
-import org.apache.cayenne.map.EJBQLQueryDescriptor;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.modeler.toolkit.text.CMTextPane;
-import java.util.Objects;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EjbqlQueryScriptsTab extends ProjectPanel implements DocumentListener {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(EjbqlQueryScriptsTab.class);
-
- protected CMTextPane scriptArea;
- private boolean updateDisabled;
- protected EJBQLStatementValidator ejbqlQueryValidator = new EJBQLStatementValidator();
-
- public EjbqlQueryScriptsTab(ProjectSession session) {
- super(session);
- initView();
- }
-
- void displayScript() {
- scriptArea.setDocumentTextDirect(getQuery().getEjbql());
- updateDisabled = false;
- }
-
- private void initView() {
-
- scriptArea = new CMUndoableTextPane(app.getUndoManager(), new EjbqlSyntax());
- scriptArea.getDocument().addDocumentListener(this);
- scriptArea.getDocument().addDocumentListener(new DocumentListener() {
-
- public void changedUpdate(DocumentEvent e) {
- }
-
- public void insertUpdate(DocumentEvent e) {
- try {
- String text = scriptArea.getDocument().getText(e.getOffset(), 1);
- if (text.equals(" ") || text.equals("\n") || text.equals("\t")) {
- getQuery().setEjbql(scriptArea.getDocumentTextDirect());
- validateEJBQL();
- }
- } catch (BadLocationException ex) {
- LOGGER.warn("Error reading document", ex);
- }
- }
-
- public void removeUpdate(DocumentEvent e) {
- getQuery().setEjbql(scriptArea.getDocumentTextDirect());
- validateEJBQL();
- }
- });
-
- scriptArea.getPane().addFocusListener(new FocusListener() {
-
- EJBQLValidationThread thread;
-
- public void focusGained(FocusEvent e) {
- thread = new EJBQLValidationThread();
- thread.start();
- }
-
- public void focusLost(FocusEvent e) {
- thread.terminate();
- }
- });
-
- scriptArea.getPane().addKeyListener(new KeyListener() {
-
- boolean pasteOrCut;
-
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_END || e.getKeyCode() == KeyEvent.VK_HOME
- || e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT
- || e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_UNDO) {
- getQuery().setEjbql(scriptArea.getText());
- validateEJBQL();
- }
- if ((e.getKeyCode() == KeyEvent.VK_V || e.getKeyCode() == KeyEvent.VK_X) && e.isControlDown()) {
- pasteOrCut = true;
- }
- }
-
- public void keyReleased(KeyEvent e) {
- if ((pasteOrCut && e.getKeyCode() == KeyEvent.VK_CONTROL) || e.getKeyCode() == KeyEvent.VK_DELETE) {
- scriptArea.removeHighlightText();
- getQuery().setEjbql(scriptArea.getText());
- validateEJBQL();
- pasteOrCut = false;
- }
- }
-
- public void keyTyped(KeyEvent e) {
- }
- });
-
- setLayout(new BorderLayout());
- add(scriptArea, BorderLayout.WEST);
- add(scriptArea.getScrollPane(), BorderLayout.CENTER);
- setVisible(true);
- }
-
- public void initFromModel() {
- QueryDescriptor query = session.getSelectedQuery();
-
- if (query == null || !QueryDescriptor.EJBQL_QUERY.equals(query.getType())) {
- setVisible(false);
- return;
- }
- scriptArea.setEnabled(true);
- displayScript();
- validateEJBQL();
- setVisible(true);
- }
-
- EJBQLQueryDescriptor getQuery() {
- QueryDescriptor query = session.getSelectedQuery();
- return (query != null && QueryDescriptor.EJBQL_QUERY.equals(query.getType())) ?
- (EJBQLQueryDescriptor) query : null;
- }
-
- void setEJBQL(DocumentEvent e) {
- Document doc = e.getDocument();
- try {
- setEJBQL(doc.getText(0, doc.getLength()));
- } catch (BadLocationException ex) {
- LOGGER.warn("Error reading document", ex);
- }
- }
-
- void setEJBQL(String text) {
- EJBQLQueryDescriptor query = getQuery();
- if (query == null) {
- return;
- }
-
- if (text != null && text.trim().isEmpty()) {
- text = null;
- }
-
- // Compare the value before modifying the query - text area
- // will call "verify" even if no changes have occured....
- if (!Objects.equals(text, query.getEjbql())) {
- query.setEjbql(text);
- session.fireQueryEvent(QueryEvent.ofChange(this, query));
- }
-
- }
-
- public void insertUpdate(DocumentEvent e) {
- changedUpdate(e);
- }
-
- public void removeUpdate(DocumentEvent e) {
- changedUpdate(e);
- }
-
- public void changedUpdate(DocumentEvent e) {
- if (!updateDisabled) {
- setEJBQL(e);
- }
- }
-
- void validateEJBQL() {
- final PositionException positionException = ejbqlQueryValidator.validateEJBQL(getQuery());
- if (positionException != null) {
-
- if (!SwingUtilities.isEventDispatchThread()) {
- SwingUtilities.invokeLater(new Runnable() {
-
- public void run() {
- if (positionException.getBeginLine() != null || positionException.getBeginColumn() != null
- || positionException.getLength() != null) {
- scriptArea.setHighlightText(positionException.getBeginLine(),
- positionException.getBeginColumn(), positionException.getLength(),
- positionException.getMessage());
- } else {
- scriptArea.removeHighlightText();
- }
- }
- });
- }
- }
- }
-
- class EJBQLValidationThread extends Thread {
-
- volatile boolean running;
- final Object timer = new Object();
- int previousCaretPosition;
- int validateCaretPosition;
-
- static final int DELAY = 500;
-
- EJBQLValidationThread() {
- super("ejbql-validation-thread");
- setDaemon(true);
- }
-
- public void run() {
- running = true;
- while (running) {
- int caretPosition = scriptArea.getCaretPosition();
- if (previousCaretPosition != 0 && previousCaretPosition == caretPosition
- && validateCaretPosition != previousCaretPosition) {
- validateEJBQL();
- validateCaretPosition = caretPosition;
- }
- previousCaretPosition = caretPosition;
- synchronized (timer) {
- try {
- timer.wait(DELAY);
- } catch (InterruptedException ignored) {
- }
- }
- }
- }
-
- void terminate() {
- synchronized (timer) {
- running = false;
- timer.notify();
- }
- }
- }
-}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlSyntax.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlSyntax.java
deleted file mode 100644
index f1a4aafd4..000000000
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlSyntax.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.modeler.ui.project.editor.query.ejbql;
-
-import org.apache.cayenne.modeler.toolkit.text.style.TextSyntax;
-
-class EjbqlSyntax implements TextSyntax {
- private static final String[] KEYWORDS = {"AS", "ABS", "ASC", "AVG", "BETWEEN",
- "BOTH", "BIT_LENGTH", "CHARACTER_LENGTH", "CHAR_LENGTH", "COUNT",
- "CONCAT", "CURRENT_TIME", "CURRENT_DATE", "CURRENT_TIMESTAMP",
- "DELETE", "DESC", "DISTINCT", "EMPTY", "ESCAPE", "FALSE", "FETCH",
- "FROM", "GROUP", "HAVING", "IS", "INNER", "LOCATE", "LOWER",
- "LEADING", "LEFT", "LENGTH", "MAX", "MEMBER", "MIN", "MOD", "NEW",
- "NULL", "OBJECT", "OF", "ORDER", "POSITION", "SELECT", "SOME",
- "SUM", "SIZE", "SQRT", "SUBSTR", "TRAILING", "TRUE", "TRIM",
- "UNKNOWN", "UPDATE", "UPPER", "USER", "WHERE", "JOIN"};
-
- private static final String[] KEYWORDS2 = {};
-
- private static final String[] TYPES = {};
-
- private static final String[] OPERATORS = {"ALL", "AND", "ANY", "BETWEEN", "BY",
- "EXISTS", "IN", "LIKE", "NOT", "NULL", "OR"};
-
-
- @Override
- public String[] keywords() {
- return KEYWORDS;
- }
-
- @Override
- public String[] keywords2() {
- return KEYWORDS2;
- }
-
- @Override
- public String[] types() {
- return TYPES;
- }
-
- @Override
- public String[] operators() {
- return OPERATORS;
- }
-
- @Override
- public String contentType() {
- return "text/ejbql";
- }
-
-}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlTabbedView.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlTabbedView.java
deleted file mode 100644
index 13825fae7..000000000
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/query/ejbql/EjbqlTabbedView.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.modeler.ui.project.editor.query.ejbql;
-
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.modeler.toolkit.ProjectTabbedPane;
-import org.apache.cayenne.modeler.project.ProjectSession;
-
-import javax.swing.JScrollPane;
-import javax.swing.JTabbedPane;
-import javax.swing.event.ChangeEvent;
-
-public class EjbqlTabbedView extends ProjectTabbedPane {
-
- private final EjbqlQueryMainTab mainTab;
- private final EjbqlQueryScriptsTab scriptsTab;
- private int lastTabIndex;
-
- public EjbqlTabbedView(ProjectSession session) {
- super(session);
- this.mainTab = new EjbqlQueryMainTab(session);
- this.scriptsTab = new EjbqlQueryScriptsTab(session);
- initLayout();
- initBindings();
- }
-
- private void initLayout() {
- setTabPlacement(JTabbedPane.TOP);
- addTab("EJBQLQuery", new JScrollPane(mainTab));
- addTab("QL", scriptsTab);
- }
-
- private void initBindings() {
- session.addQueryDisplayListener(e -> initFromModel());
- addChangeListener(this::stateChanged);
- }
-
- private void stateChanged(ChangeEvent e) {
- lastTabIndex = getSelectedIndex();
- updateTabs();
- }
-
- private void initFromModel() {
- if (!QueryDescriptor.EJBQL_QUERY.equals(session.getSelectedQuery().getType())) {
- setVisible(false);
- return;
- }
-
- // tab did not change - force update
- if (getSelectedIndex() == lastTabIndex) {
- updateTabs();
- }
- // change tab, this will update newly displayed tab...
- else {
- setSelectedIndex(lastTabIndex);
- }
-
- setVisible(true);
- }
-
- private void updateTabs() {
- switch (lastTabIndex) {
- case 0:
- mainTab.initFromModel();
- break;
- case 1:
- scriptsTab.initFromModel();
- break;
- }
- }
-}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/querytype/QueryTypeDialog.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/querytype/QueryTypeDialog.java
index 1d50e20d4..0608facd2 100644
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/querytype/QueryTypeDialog.java
+++ b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/querytype/QueryTypeDialog.java
@@ -39,7 +39,7 @@ import java.awt.BorderLayout;
import java.awt.Window;
/**
- * Modal dialog for picking the type of new query (Select, SQLTemplate, Procedure, EJBQL)
+ * Modal dialog for picking the type of new query (Select, SQLTemplate, Procedure)
* before adding it to the current DataMap.
*/
public class QueryTypeDialog extends ProjectDialog {
@@ -50,7 +50,6 @@ public class QueryTypeDialog extends ProjectDialog {
private final JRadioButton objectSelect;
private final JRadioButton sqlSelect;
private final JRadioButton procedureSelect;
- private final JRadioButton ejbqlSelect;
private final JButton createButton;
private final JButton cancelButton;
@@ -62,14 +61,12 @@ public class QueryTypeDialog extends ProjectDialog {
this.objectSelect = new JRadioButton("ObjectSelect");
this.sqlSelect = new JRadioButton("SQLTemplate");
this.procedureSelect = new JRadioButton("ProcedureQuery");
- this.ejbqlSelect = new JRadioButton("EJBQLQuery");
objectSelect.setSelected(true);
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(objectSelect);
buttonGroup.add(sqlSelect);
buttonGroup.add(procedureSelect);
- buttonGroup.add(ejbqlSelect);
this.createButton = new JButton("Create");
this.cancelButton = new JButton("Cancel");
@@ -95,13 +92,12 @@ public class QueryTypeDialog extends ProjectDialog {
CellConstraints cc = new CellConstraints();
FormLayout layout = new FormLayout(
"left:max(180dlu;pref)",
- "p, 4dlu, p, 4dlu, p, 4dlu, p, 4dlu");
+ "p, 4dlu, p, 4dlu, p, 4dlu");
PanelBuilder builder = new PanelBuilder(layout);
builder.setDefaultDialogBorder();
builder.add(objectSelect, cc.xy(1, 1));
builder.add(sqlSelect, cc.xy(1, 3));
builder.add(procedureSelect, cc.xy(1, 5));
- builder.add(ejbqlSelect, cc.xy(1, 7));
setLayout(new BorderLayout());
add(builder.getPanel(), BorderLayout.CENTER);
@@ -129,7 +125,6 @@ public class QueryTypeDialog extends ProjectDialog {
private String selectedQueryType() {
if (sqlSelect.isSelected()) return QueryDescriptor.SQL_TEMPLATE;
if (procedureSelect.isSelected()) return QueryDescriptor.PROCEDURE_QUERY;
- if (ejbqlSelect.isSelected()) return QueryDescriptor.EJBQL_QUERY;
return QueryDescriptor.SELECT_QUERY;
}
}
diff --git a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
index 93bf23cfd..ad6e3f8fa 100644
--- a/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
+++ b/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
@@ -26,7 +26,6 @@ import org.apache.cayenne.map.ObjEntity;
import org.apache.cayenne.modeler.ui.project.ProjectView;
import org.apache.cayenne.modeler.ui.project.editor.EditorPanelView;
import org.apache.cayenne.modeler.ui.project.editor.query.sqltemplate.SQLTemplateTabbedView;
-import org.apache.cayenne.query.EJBQLQuery;
import org.apache.cayenne.query.SQLTemplate;
import javax.swing.*;
@@ -93,10 +92,6 @@ public class TextCompoundEdit extends CompoundEdit implements DocumentListener {
}
}
- if (targetObject instanceof EJBQLQuery) {
- tabbedPane = editorPanel.getEjbqlQueryView();
- }
-
if (targetObject instanceof DataMap) {
tabbedPane = editorPanel.getDataMapView();
}
diff --git a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/DefaultProjectValidator.java b/cayenne-project/src/main/java/org/apache/cayenne/project/validation/DefaultProjectValidator.java
index 23681d77d..939f60d2d 100644
--- a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/DefaultProjectValidator.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/validation/DefaultProjectValidator.java
@@ -25,7 +25,6 @@ import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.map.DbAttribute;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.EJBQLQueryDescriptor;
import org.apache.cayenne.map.Embeddable;
import org.apache.cayenne.map.EmbeddableAttribute;
import org.apache.cayenne.map.ObjAttribute;
@@ -81,7 +80,6 @@ public class DefaultProjectValidator implements ProjectValidator {
validators.put(ProcedureParameter.class, new ProcedureParameterValidator(configSupplier));
validators.put(SelectQueryDescriptor.class, new SelectQueryValidator(configSupplier));
validators.put(ProcedureQueryDescriptor.class, new ProcedureQueryValidator(configSupplier));
- validators.put(EJBQLQueryDescriptor.class, new EJBQLQueryValidator(configSupplier));
validators.put(SQLTemplateDescriptor.class, new SQLTemplateValidator(configSupplier));
return validators;
}
@@ -227,9 +225,6 @@ public class DefaultProjectValidator implements ProjectValidator {
case QueryDescriptor.PROCEDURE_QUERY:
getValidator(ProcedureQueryDescriptor.class).validate((ProcedureQueryDescriptor) query, validationResult);
break;
- case QueryDescriptor.EJBQL_QUERY:
- getValidator(EJBQLQueryDescriptor.class).validate((EJBQLQueryDescriptor) query, validationResult);
- break;
}
return validationResult;
diff --git a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLQueryValidator.java b/cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLQueryValidator.java
deleted file mode 100644
index 3a6cb5bb1..000000000
--- a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLQueryValidator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.project.validation;
-
-import org.apache.cayenne.project.validation.EJBQLStatementValidator.PositionException;
-import org.apache.cayenne.map.EJBQLQueryDescriptor;
-import org.apache.cayenne.validation.ValidationResult;
-
-import java.util.function.Supplier;
-
-class EJBQLQueryValidator extends BaseQueryValidator<EJBQLQueryDescriptor> {
-
- /**
- * @param configSupplier the config defining the behavior of this validator.
- * @since 5.0
- */
- public EJBQLQueryValidator(Supplier<ValidationConfig> configSupplier) {
- super(configSupplier);
- }
-
- @Override
- protected ConfigurationNodeValidator<EJBQLQueryDescriptor>.Performer<EJBQLQueryDescriptor> validateQuery(
- EJBQLQueryDescriptor query, ValidationResult validationResult) {
- return super.validateQuery(query, validationResult)
- .performIfEnabled(Inspection.EJBQL_QUERY_INVALID_SYNTAX, this::validateSyntax);
- }
-
- private void validateSyntax(EJBQLQueryDescriptor query, ValidationResult validationResult) {
- PositionException message = new EJBQLStatementValidator().validateEJBQL(query);
- if (message != null) {
- addFailure(validationResult, query, "Error in EJBQL query '%s' syntax", query.getName());
- }
- }
-}
diff --git a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLStatementValidator.java b/cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLStatementValidator.java
deleted file mode 100644
index 68a56854e..000000000
--- a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/EJBQLStatementValidator.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.project.validation;
-
-import java.lang.reflect.Field;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLParserFactory;
-import org.apache.cayenne.map.EJBQLQueryDescriptor;
-
-public class EJBQLStatementValidator {
-
- public PositionException validateEJBQL(EJBQLQueryDescriptor query) {
- if (query.getEjbql() != null) {
- PositionException message = null;
-
- try {
- // Only parse query and validate it's syntax.
- // It still may be invalid e.g. invalid entities used.
- // We can't call compile() for the full check as it will try to get
- // Class objects for ObjEntities used in query that are not available
- // in the modeler
- EJBQLParserFactory.getParser().parse(query.getEjbql());
- } catch (CayenneRuntimeException e) {
- message = new PositionException();
- message.setE(e);
- if (e.getCause() != null) {
-
- message.setMessage(e.getCause().getMessage());
-
- if (e instanceof EJBQLException) {
- EJBQLException ejbqlException = (EJBQLException) e;
- Throwable cause = ejbqlException.getCause();
-
- if (cause != null) {
- try {
- Field tokenField = cause.getClass().getField("currentToken");
- Object token = tokenField.get(cause);
- Field nextTokenField = token.getClass().getField("next");
- Object nextToken = nextTokenField.get(token);
- Field beginColumnField = nextToken.getClass().getField("beginColumn");
- Field beginLineField = nextToken.getClass().getField("beginLine");
- Field endColumnField = nextToken.getClass().getField("endColumn");
- Field endLineField = nextToken.getClass().getField("endLine");
- Field imageField = nextToken.getClass().getField("image");
-
- message.setBeginColumn((Integer) beginColumnField.get(nextToken));
- message.setBeginLine((Integer) beginLineField.get(nextToken));
- message.setEndColumn((Integer) endColumnField.get(nextToken));
- message.setEndLine((Integer) endLineField.get(nextToken));
- message.setImage((String) imageField.get(nextToken));
- message.setLength(message.getImage().length());
- } catch (Exception e1) {
- throw new CayenneRuntimeException(e1);
- }
- }
- }
- } else {
- message.setE(e);
- message.setMessage(e.getUnlabeledMessage());
- }
- } catch (Throwable e) {
- message = new PositionException();
- if(e instanceof Exception) {
- message.setE((Exception)e);
- }
- message.setMessage(e.getMessage());
- }
-
- return message;
- }
- else {
- return null;
- }
- }
-
- public class PositionException {
-
- private Integer beginColumn;
- private Integer beginLine;
- private Integer endColumn;
- private Integer endLine;
- private Integer length;
- private String image;
- private String message;
- private Exception e;
-
- public Integer getLength() {
- return length;
- }
-
- public void setLength(Integer length) {
- this.length = length;
- }
-
- public Exception getE() {
- return e;
- }
-
- public void setE(Exception e) {
- this.e = e;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public Integer getBeginColumn() {
- return beginColumn;
- }
-
- public void setBeginColumn(Integer beginColumn) {
- this.beginColumn = beginColumn;
- }
-
- public Integer getBeginLine() {
- return beginLine;
- }
-
- public void setBeginLine(Integer beginLine) {
- this.beginLine = beginLine;
- }
-
- public Integer getEndColumn() {
- return endColumn;
- }
-
- public void setEndColumn(Integer endColumn) {
- this.endColumn = endColumn;
- }
-
- public Integer getEndLine() {
- return endLine;
- }
-
- public void setEndLine(Integer endLine) {
- this.endLine = endLine;
- }
-
- public String getImage() {
- return image;
- }
-
- public void setImage(String image) {
- this.image = image;
- }
- }
-}
diff --git a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/Inspection.java b/cayenne-project/src/main/java/org/apache/cayenne/project/validation/Inspection.java
index f83b70f58..b0eeed3c6 100644
--- a/cayenne-project/src/main/java/org/apache/cayenne/project/validation/Inspection.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/validation/Inspection.java
@@ -105,8 +105,6 @@ public enum Inspection {
PROCEDURE_QUERY_NO_ROOT(Group.PROCEDURE_QUERY, "Empty procedure query root"),
PROCEDURE_QUERY_INVALID_ROOT(Group.PROCEDURE_QUERY, "Invalid procedure query root"),
- EJBQL_QUERY_INVALID_SYNTAX(Group.EJBQL_QUERY, "Invalid syntax of an EJBQL query"),
-
SQL_TEMPLATE_NO_ROOT(Group.SQL_TEMPLATE, "Empty SQL template query root"),
SQL_TEMPLATE_NO_DEFAULT_SQL(Group.SQL_TEMPLATE, "SQL template query has no default SQL template");
@@ -181,7 +179,6 @@ public enum Inspection {
QUERY("Query"),
SELECT_QUERY("Select query"),
PROCEDURE_QUERY("Procedure query"),
- EJBQL_QUERY("EJBQL query"),
SQL_TEMPLATE("SQL template");
private final String readableName;
diff --git a/cayenne-velocity/src/main/java/org/apache/cayenne/velocity/ResultDirective.java b/cayenne-velocity/src/main/java/org/apache/cayenne/velocity/ResultDirective.java
index 978d7f8ac..caa1b5818 100644
--- a/cayenne-velocity/src/main/java/org/apache/cayenne/velocity/ResultDirective.java
+++ b/cayenne-velocity/src/main/java/org/apache/cayenne/velocity/ResultDirective.java
@@ -135,10 +135,8 @@ public class ResultDirective extends Directive {
.get(VelocitySQLTemplateTranslator.ADAPTER_KEY);
ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(javaClass);
- // TODO: andrus 6/27/2007 - this is an unofficial jdbcType parameter
- // that is added
- // temporarily pending CAY-813 implementation for the sake of EJBQL
- // query...
+ // TODO: andrus 6/27/2007 - this is an unofficial jdbcType parameter, added temporarily pending CAY-813
+ // implementation (originally for the sake of the now removed EJBQL queries)
Object jdbcTypeChild = getChild(context, node, 4);
int jdbcType = (jdbcTypeChild instanceof Number) ? ((Number) jdbcTypeChild).intValue() : 0;
diff --git a/cayenne/pom.xml b/cayenne/pom.xml
index c8add1f67..fdb59a892 100644
--- a/cayenne/pom.xml
+++ b/cayenne/pom.xml
@@ -84,64 +84,23 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javacc-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>jjtree-ejbql</id>
- <phase>generate-sources</phase>
- <configuration>
- <sourceDirectory>
- ${basedir}/src/main/jjtree/org/apache/cayenne/ejbql
- </sourceDirectory>
- <outputDirectory>
- ${project.build.directory}/generated-sources/javacc/org/apache/cayenne/ejbql
- </outputDirectory>
- <buildNodeFiles>false</buildNodeFiles>
- <grammarEncoding>UTF-8</grammarEncoding>
- </configuration>
- <goals>
- <goal>jjtree-javacc</goal>
- </goals>
- </execution>
- <!--
- src/main/jjtree/org/apache/cayenne/ql for now is generated
- outside of Maven with JavaCC 7.0.13 command line tools.
- Copy QLParser.jjt to an empty directory, and run there:
- $ JAVACC=~/.m2/repository/net/java/dev/javacc/javacc/7.0.13/javacc-7.0.13.jar
- # Parser grammar out of tree grammar:
- $ java -cp $JAVACC jjtree QLParser.jjt
- # Parser java code:
- $ java -cp $JAVACC javacc QLParser.jj
+ <!--
+ src/main/jjtree/org/apache/cayenne/ql is generated outside of Maven with JavaCC 7.0.13 command
+ line tools. Copy QLParser.jjt to an empty directory, and run there:
+ $ JAVACC=~/.m2/repository/net/java/dev/javacc/javacc/7.0.13/javacc-7.0.13.jar
+ # Parser grammar out of tree grammar:
+ $ java -cp $JAVACC jjtree QLParser.jjt
+ # Parser java code:
+ $ java -cp $JAVACC javacc QLParser.jj
- # Copy these generated classes to src/main/java/org/apache/cayenne/ql:
- # QLParser, QLParserTokenManager, QLParserConstants, QLParserTreeConstants
- # Everything else (the node classes, JJTQLParserState, JavaCharStream, Token,
- # ParseException, TokenMgrError) is maintained by hand and must not be overwritten.
+ # Copy these generated classes to src/main/java/org/apache/cayenne/ql:
+ # QLParser, QLParserTokenManager, QLParserConstants, QLParserTreeConstants
+ # Everything else (the node classes, JJTQLParserState, JavaCharStream, Token,
+ # ParseException, TokenMgrError) is maintained by hand and must not be overwritten.
- # docs
- $ java -cp $JAVACC jjdoc -TEXT=true QLParser.jj
- -->
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-sources</phase>
- <configuration>
- <target>
- <!-- This will remove duplicate Node file -->
- <delete file="${project.build.directory}/generated-sources/jjtree/org/apache/cayenne/ejbql/parser/Node.java" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ # docs
+ $ java -cp $JAVACC jjdoc -TEXT=true QLParser.jj
+ -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<!-- include OSGi stuff -->
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataNode.java b/cayenne/src/main/java/org/apache/cayenne/access/DataNode.java
index 9c1f3d56e..117b6719c 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataNode.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataNode.java
@@ -23,7 +23,6 @@ import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.access.dbsync.SchemaUpdateStrategy;
import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
import org.apache.cayenne.access.translator.BatchTranslator;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.translator.SQLTemplateTranslator;
import org.apache.cayenne.access.translator.SelectTranslator;
@@ -80,7 +79,6 @@ public class DataNode {
private BatchTranslator<DeleteBatchQuery> deleteBatchTranslator;
private SelectTranslator selectTranslator;
private ProcedureTranslator procedureTranslator;
- private EJBQLTranslator ejbqlTranslator;
private SQLTemplateTranslator sqlTemplateTranslator;
/**
@@ -463,20 +461,6 @@ public class DataNode {
this.procedureTranslator = procedureTranslator;
}
- /**
- * @since 5.0
- */
- public EJBQLTranslator getEjbqlTranslator() {
- return ejbqlTranslator;
- }
-
- /**
- * @since 5.0
- */
- public void setEjbqlTranslator(EJBQLTranslator ejbqlTranslator) {
- this.ejbqlTranslator = ejbqlTranslator;
- }
-
// a read-through DataSource that ensures returning the same connection
// within transaction.
static class TransactionDataSource implements DataSource {
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataRowStore.java b/cayenne/src/main/java/org/apache/cayenne/access/DataRowStore.java
index a35b04943..c277459ae 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataRowStore.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataRowStore.java
@@ -130,7 +130,7 @@ public class DataRowStore {
for (int i = 0; i < size; i++) {
Persistent object = objects.get(i);
- // skip null objects... possible since 3.0 in some EJBQL results
+ // skip null objects... possible in some query results, e.g. with an outer join in a SQLTemplate
if (object == null) {
continue;
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/ObjectResolver.java b/cayenne/src/main/java/org/apache/cayenne/access/ObjectResolver.java
index 2995b5891..610ec386a 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/ObjectResolver.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/ObjectResolver.java
@@ -115,8 +115,7 @@ class ObjectResolver {
List<Persistent> results = new ArrayList<>(rows.size());
for (DataRow row : rows) {
- // nulls are possible here since 3.0 for some varieties of EJBQL,
- // simple example of this: "select p.toGallery+ from Painting p" where toGallery is null.
+ // nulls are possible here, e.g. for an outer join in a SQLTemplate that resolves to no object
results.add(objectFromDataRow(row));
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java b/cayenne/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
deleted file mode 100644
index c46e84697..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.jdbc;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.ResultIterator;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.OperationObserver;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.access.translator.TranslatedStatement;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-import org.apache.cayenne.query.EJBQLQuery;
-import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.QueryMetadata;
-import org.apache.cayenne.query.SQLActionVisitor;
-import org.apache.cayenne.query.SQLTemplate;
-
-import java.sql.Connection;
-import java.util.List;
-
-/**
- * Parses an EJBQL statement, converting it to SQL. Executes the resulting SQL.
- *
- * @since 3.0
- */
-public class EJBQLAction extends BaseSQLAction {
-
- protected SQLActionVisitor actionFactory;
- protected EJBQLQuery<?> query;
-
- public EJBQLAction(EJBQLQuery<?> query, SQLActionVisitor actionFactory, DataNode dataNode) {
- super(dataNode);
-
- this.query = query;
- this.actionFactory = actionFactory;
- }
-
- @Override
- public void performAction(Connection connection, OperationObserver observer) throws Exception {
- EJBQLCompiledExpression compiledExpression = query.getExpression(dataNode.getEntityResolver());
- EJBQLTranslator translator = dataNode.getEjbqlTranslator();
-
- DbEntity rootDbEntity = compiledExpression.getRootDescriptor().getEntity().getDbEntity();
- QuotingStrategy quotingStrategy = dataNode.getAdapter().getQuotingStrategy(rootDbEntity);
-
- EJBQLTranslationContext context = new EJBQLTranslationContext(
- dataNode.getEntityResolver(),
- query,
- compiledExpression,
- translator,
- dataNode.getAdapter(),
- quotingStrategy);
-
- compiledExpression.getExpression().visit(new EJBQLBaseVisitor(false) {
-
- @Override
- public boolean visitSelect(EJBQLExpression expression) {
- EJBQLExpressionVisitor visitor = translator.getSelectTranslator(context);
- expression.visit(visitor);
- return false;
- }
-
- @Override
- public boolean visitDelete(EJBQLExpression expression) {
- EJBQLExpressionVisitor visitor = translator.getDeleteTranslator(context);
- expression.visit(visitor);
- return false;
- }
-
- @Override
- public boolean visitUpdate(EJBQLExpression expression) {
- EJBQLExpressionVisitor visitor = translator.getUpdateTranslator(context);
- expression.visit(visitor);
- return false;
- }
- });
-
- SQLTemplate<?> sqlQuery = context.getQuery();
-
- // update with metadata
- QueryMetadata md = query.getMetaData(dataNode.getEntityResolver());
- sqlQuery.setFetchLimit(md.getFetchLimit());
- sqlQuery.setFetchOffset(md.getFetchOffset());
- sqlQuery.setResult(compiledExpression.getResult());
- sqlQuery.setPageSize(md.getPageSize());
-
- if (md.getStatementFetchSize() != 0) {
- sqlQuery.setStatementFetchSize(md.getStatementFetchSize());
- }
-
- int queryTimeout = md.getQueryTimeout();
- if (queryTimeout != QueryMetadata.QUERY_TIMEOUT_DEFAULT) {
- sqlQuery.setQueryTimeout(queryTimeout);
- }
-
- // the SQLTemplate is a substitute for the original EJBQLQuery; wrap the observer so that results are reported
- // against the EJBQLQuery the caller submitted rather than the internally compiled SQLTemplate
- actionFactory.sqlAction(sqlQuery).performAction(connection, new OriginalQueryObserver(observer, query));
- }
-
- static class OriginalQueryObserver implements OperationObserver {
-
- private final OperationObserver delegate;
- private final Query originalQuery;
-
- OriginalQueryObserver(OperationObserver delegate, Query originalQuery) {
- this.delegate = delegate;
- this.originalQuery = originalQuery;
- }
-
- @Override
- public void nextStatement(Query query, TranslatedStatement statement) {
- delegate.nextStatement(originalQuery, statement);
- }
-
- @Override
- public void onSuccess() {
- delegate.onSuccess();
- }
-
- @Override
- public void nextCount(Query query, int resultCount) {
- delegate.nextCount(originalQuery, resultCount);
- }
-
- @Override
- public void nextBatchCount(Query query, int[] resultCount) {
- delegate.nextBatchCount(originalQuery, resultCount);
- }
-
- @Override
- public void nextRows(Query query, List<?> dataRows) {
- delegate.nextRows(originalQuery, dataRows);
- }
-
- @Override
- public void nextRows(Query query, ResultIterator<?> it) {
- delegate.nextRows(originalQuery, it);
- }
-
- @Override
- public void nextGeneratedRows(Query query, List<DataRow> keys, List<ObjectId> idsToUpdate) {
- delegate.nextGeneratedRows(originalQuery, keys, idsToUpdate);
- }
-
- @Override
- public void nextQueryException(Query query, Exception ex) {
- delegate.nextQueryException(originalQuery, ex);
- }
-
- @Override
- public void nextGlobalException(Exception ex) {
- delegate.nextGlobalException(ex);
- }
-
- @Override
- public boolean isIteratedResult() {
- return delegate.isIteratedResult();
- }
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/jdbc/reader/DefaultRowReaderFactory.java b/cayenne/src/main/java/org/apache/cayenne/access/jdbc/reader/DefaultRowReaderFactory.java
index ea81094cb..935435fef 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/jdbc/reader/DefaultRowReaderFactory.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/jdbc/reader/DefaultRowReaderFactory.java
@@ -173,8 +173,8 @@ public class DefaultRowReaderFactory implements RowReaderFactory {
}
if (found != pkLen) {
- // TODO: HACK: the result columns don't carry resolvable PK DbAttributes (these are most likely aliased
- // EJBQL columns). Fall back to the legacy assumption that the PK is the first pkLen columns starting at
+ // TODO: HACK: the result columns don't carry resolvable PK DbAttributes (e.g. aliased
+ // columns). Fall back to the legacy assumption that the PK is the first pkLen columns starting at
// 'from'.
if (from + pkLen > columns.length) {
throw new CayenneRuntimeException(
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/EJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/EJBQLTranslator.java
deleted file mode 100644
index d8dc54cc5..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/EJBQLTranslator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLJoinAppender;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * A stateless service that produces translation visitors of EJBQL. DbAdapters can customize EJBQL
- * translation by providing their own implementation.
- *
- * @since 3.0
- */
-public interface EJBQLTranslator {
-
- EJBQLJoinAppender getJoinAppender(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getSelectTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getDeleteTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getUpdateTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getAggregateColumnTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getFromTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getGroupByTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getIdentifierColumnsTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getOrderByTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getSelectColumnsTranslator(EJBQLTranslationContext context);
-
- EJBQLExpressionVisitor getUpdateItemTranslator(EJBQLTranslationContext context);
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/DbAdapterDelegatedEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/DbAdapterDelegatedEJBQLTranslator.java
deleted file mode 100644
index 0d045b23e..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/DbAdapterDelegatedEJBQLTranslator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * An {@link EJBQLTranslator} that resolves the actual translator from {@link org.apache.cayenne.dba.DbAdapter#getEjbqlTranslator()}
- * allowing adapters to customize translation. The adapter is obtained from the {@link EJBQLTranslationContext}.
- *
- * @since 5.0
- */
-public class DbAdapterDelegatedEJBQLTranslator implements EJBQLTranslator {
-
- @Override
- public EJBQLJoinAppender getJoinAppender(EJBQLTranslationContext context) {
- return delegate(context).getJoinAppender(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getSelectTranslator(EJBQLTranslationContext context) {
- return delegate(context).getSelectTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getDeleteTranslator(EJBQLTranslationContext context) {
- return delegate(context).getDeleteTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getUpdateTranslator(EJBQLTranslationContext context) {
- return delegate(context).getUpdateTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getAggregateColumnTranslator(EJBQLTranslationContext context) {
- return delegate(context).getAggregateColumnTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- return delegate(context).getConditionTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getFromTranslator(EJBQLTranslationContext context) {
- return delegate(context).getFromTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getGroupByTranslator(EJBQLTranslationContext context) {
- return delegate(context).getGroupByTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getIdentifierColumnsTranslator(EJBQLTranslationContext context) {
- return delegate(context).getIdentifierColumnsTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getOrderByTranslator(EJBQLTranslationContext context) {
- return delegate(context).getOrderByTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getSelectColumnsTranslator(EJBQLTranslationContext context) {
- return delegate(context).getSelectColumnsTranslator(context);
- }
-
- @Override
- public EJBQLExpressionVisitor getUpdateItemTranslator(EJBQLTranslationContext context) {
- return delegate(context).getUpdateItemTranslator(context);
- }
-
- private EJBQLTranslator delegate(EJBQLTranslationContext context) {
- return context.getAdapter().getEjbqlTranslator();
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLAggregateColumnTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLAggregateColumnTranslator.java
deleted file mode 100644
index 32b46f1b0..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLAggregateColumnTranslator.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Collection;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-import org.apache.cayenne.ejbql.parser.EJBQLAggregateColumn;
-import org.apache.cayenne.ejbql.parser.EJBQLIntegerLiteral;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-/**
- * @since 3.0
- */
-class EJBQLAggregateColumnTranslator extends EJBQLBaseVisitor {
-
- private EJBQLTranslationContext context;
- private String attributeType;
-
- EJBQLAggregateColumnTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- @Override
- public boolean visitCount(EJBQLAggregateColumn expression) {
- visitAggregateColumn(expression, new CountColumnVisitor());
- return false;
- }
-
- @Override
- public boolean visitAverage(EJBQLAggregateColumn expression) {
- visitAggregateColumn(expression, new FieldPathTranslator());
- return false;
- }
-
- @Override
- public boolean visitMax(EJBQLAggregateColumn expression) {
- visitAggregateColumn(expression, new FieldPathTranslator());
- return false;
- }
-
- @Override
- public boolean visitMin(EJBQLAggregateColumn expression) {
- visitAggregateColumn(expression, new FieldPathTranslator());
- return false;
- }
-
- @Override
- public boolean visitSum(EJBQLAggregateColumn expression) {
- visitAggregateColumn(expression, new FieldPathTranslator());
- return false;
- }
-
- private void visitAggregateColumn(EJBQLAggregateColumn column, EJBQLExpressionVisitor pathVisitor) {
-
- if (context.isAppendingResultColumns()) {
- context.append(" #result('");
- } else {
- context.append(' ');
- }
-
- context.append(column.getFunction()).append('(');
-
- // path visitor must set attributeType ivar
- column.visit(pathVisitor);
- context.append(')');
-
- if (context.isAppendingResultColumns()) {
- context.append("' '").append(column.getJavaType(attributeType)).append("' '")
- .append(context.nextColumnAlias()).append("')");
- }
- }
-
- /**
- * This method tries to find mandatory PK attribute, if no such exists returns first PK attribute.
- * Used to translate COUNT(entity) expressions into COUNT(alias.pk_column).
- */
- private DbAttribute getPk(DbEntity dbEntity) {
- for(DbAttribute attribute : dbEntity.getPrimaryKeys()) {
- if(attribute.isMandatory()) {
- return attribute;
- }
- }
-
- return dbEntity.getPrimaryKeys().iterator().next();
- }
-
- class FieldPathTranslator extends EJBQLPathTranslator {
-
- FieldPathTranslator() {
- super(EJBQLAggregateColumnTranslator.this.context);
- }
-
- @Override
- public boolean visitDistinct(EJBQLExpression expression) {
- context.append("DISTINCT ");
- return true;
- }
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- throw new EJBQLException("Can't use multi-column paths in column clause");
- }
-
- @Override
- protected void processTerminatingAttribute(ObjAttribute attribute) {
-
- EJBQLAggregateColumnTranslator.this.attributeType = attribute.getType();
-
- DbEntity table = currentEntity.getDbEntity();
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
- context.append(alias).append('.')
- .append(quotes.quoted(attribute.getDbAttribute().getName()));
- }
-
- @Override
- protected void processTerminatingRelationship(ObjRelationship relationship) {
- Collection<DbAttribute> dbAttr = relationship.getTargetEntity().getDbEntity().getAttributes();
-
- if (dbAttr.size() > 0) {
- resolveJoin();
- }
-
- DbAttribute pk = getPk(relationship.getTargetEntity().getDbEntity());
- QuotingStrategy quotes = context.getIdentifierQuotes();
- context.append(lastAlias).append('.').append(quotes.quoted(pk.getName()));
- }
- }
-
- class CountColumnVisitor extends EJBQLBaseVisitor {
-
- @Override
- public boolean visitDistinct(EJBQLExpression expression) {
- context.append("DISTINCT ");
- return true;
- }
-
- @Override
- public boolean visitIntegerLiteral(EJBQLIntegerLiteral expression) {
- // this allows to use COUNT(1) in EJBQL
- context.append(expression.getText());
- return false;
- }
-
- @Override
- public boolean visitIdentifier(EJBQLExpression expression) {
- ClassDescriptor classDescriptor = context.getCompiledExpression().getEntityDescriptor(expression.getText());
- if(classDescriptor == null) {
- throw new EJBQLException("Unmapped id variable: " + expression.getText());
- }
-
- DbEntity dbEntity = classDescriptor.getEntity().getDbEntity();
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String tableName = quotes.quotedFQN(dbEntity.getCatalog(), dbEntity.getSchema(), dbEntity.getName());
- context.append(context.getTableAlias(expression.getText(), tableName))
- .append('.').append(quotes.quoted(getPk(dbEntity).getName()));
- return false;
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
- expression.visit(new FieldPathTranslator());
- return false;
- }
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLConditionTranslator.java
deleted file mode 100644
index 18510fc0d..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLConditionTranslator.java
+++ /dev/null
@@ -1,1180 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.Persistent;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.dba.TypesMapping;
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.parser.AggregateConditionNode;
-import org.apache.cayenne.ejbql.parser.EJBQLDecimalLiteral;
-import org.apache.cayenne.ejbql.parser.EJBQLEquals;
-import org.apache.cayenne.ejbql.parser.EJBQLIdentificationVariable;
-import org.apache.cayenne.ejbql.parser.EJBQLIntegerLiteral;
-import org.apache.cayenne.ejbql.parser.EJBQLNamedInputParameter;
-import org.apache.cayenne.ejbql.parser.EJBQLPath;
-import org.apache.cayenne.ejbql.parser.EJBQLPositionalInputParameter;
-import org.apache.cayenne.ejbql.parser.EJBQLSubselect;
-import org.apache.cayenne.ejbql.parser.EJBQLTrimBoth;
-import org.apache.cayenne.ejbql.parser.EJBQLTrimSpecification;
-import org.apache.cayenne.ejbql.parser.Node;
-import org.apache.cayenne.ejbql.parser.SimpleNode;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.reflect.AttributeProperty;
-import org.apache.cayenne.reflect.ClassDescriptor;
-import org.apache.cayenne.reflect.PropertyDescriptor;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @since 3.0
- */
-public class EJBQLConditionTranslator extends EJBQLBaseVisitor {
-
- protected EJBQLTranslationContext context;
- protected List<EJBQLMultiColumnOperand> multiColumnOperands;
-
- public EJBQLConditionTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- protected void addMultiColumnOperand(EJBQLMultiColumnOperand operand) {
- if (multiColumnOperands == null) {
- multiColumnOperands = new ArrayList<>(2);
- }
-
- multiColumnOperands.add(operand);
- }
-
- @Override
- public boolean visitAggregate(EJBQLExpression expression) {
- expression.visit(context.getTranslator().getAggregateColumnTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitAnd(EJBQLExpression expression, int finishedChildIndex) {
- visitConditional((AggregateConditionNode) expression, " AND", finishedChildIndex);
- return true;
- }
-
- @Override
- public boolean visitBetween(EJBQLExpression expression, int finishedChildIndex) {
- switch (finishedChildIndex) {
- case 0:
- if (expression.isNegated()) {
- context.append(" NOT");
- }
- context.append(" BETWEEN");
- break;
- case 1:
- context.append(" AND");
- break;
- }
-
- return true;
- }
-
- @Override
- public boolean visitExists(EJBQLExpression expression) {
- context.append(" EXISTS");
- return true;
- }
-
- @Override
- public boolean visitIsEmpty(EJBQLExpression expression) {
-
- // handle as "path is [not] null" (an alt. way would've been a
- // correlated subquery
- // on the target entity)...
-
- if (expression.isNegated()) {
- context.pushMarker(context.makeDistinctMarker(), true);
- context.append(" DISTINCT");
- context.popMarker();
- }
-
- visitIsNull(expression, -1);
- for (int i = 0; i < expression.getChildrenCount(); i++) {
- expression.getChild(i).visit(this);
- visitIsNull(expression, i);
- }
-
- return false;
- }
-
- @Override
- public boolean visitSize(EJBQLExpression expression) {
-
- // run as a correlated subquery.
- // see "visitMemberOf" for correlated subquery logic
- // also note that the code below is mostly copy/paste from MEMBER OF
- // method ...
- // maybe there's enough commonality in building correlated subqueries to
- // make it
- // reusable???
-
- if (expression.getChildrenCount() != 1) {
- throw new EJBQLException("SIZE must have exactly one child, got: " + expression.getChildrenCount());
- }
-
- if (!(expression.getChild(0) instanceof EJBQLPath)) {
- throw new EJBQLException("First child of SIZE must be a collection path, got: " + expression.getChild(1));
- }
-
-
- EJBQLPath path = (EJBQLPath) expression.getChild(0);
-
- String id = path.getAbsolutePath();
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String correlatedEntityId = path.getId();
- ClassDescriptor correlatedEntityDescriptor = context.getEntityDescriptor(correlatedEntityId);
- DbEntity correlatedDbEntity = correlatedEntityDescriptor.getEntity().getDbEntity();
- String correlatedTableName = quotes.quotedFQN(correlatedDbEntity.getCatalog(), correlatedDbEntity.getSchema(),
- correlatedDbEntity.getName());
- String correlatedTableAlias = context.getTableAlias(correlatedEntityId, correlatedTableName);
-
- String subqueryId = context.createIdAlias(id);
- ClassDescriptor targetDescriptor = context.getEntityDescriptor(subqueryId);
-
- if (expression.isNegated()) {
- context.append(" NOT");
- }
-
- context.append(" EXISTS (SELECT 1 FROM ");
-
- DbEntity subqueryDbEntity = targetDescriptor.getEntity().getDbEntity();
- String subqueryTableName = quotes.quotedFQN(subqueryDbEntity.getCatalog(), subqueryDbEntity.getSchema(),
- subqueryDbEntity.getName());
- String subqueryRootAlias = context.getTableAlias(subqueryId, subqueryTableName);
-
- ObjRelationship relationship = correlatedEntityDescriptor.getEntity().getRelationship(path.getRelativePath());
-
- if (relationship.getDbRelationshipPath().length() > 1) {
- // if the DbRelationshipPath contains '.', the relationship is flattened
- subqueryRootAlias = processFlattenedRelationShip(subqueryRootAlias, relationship);
- } else {
- // not using "AS" to separate table name and alias name -
- // OpenBase doesn't support "AS", and the rest of the databases do not care
- context.append(subqueryTableName).append(' ').append(subqueryRootAlias);
-
- }
- context.append(" WHERE");
-
- DbRelationship correlatedJoinRelationship = context.getIncomingRelationships(new EJBQLTableId(id)).get(0);
- Iterator<DbJoin> it = correlatedJoinRelationship.getJoins().iterator();
- while (it.hasNext()) {
- DbJoin join = it.next();
- context.append(' ').append(subqueryRootAlias).append('.').append(join.getTargetName()).append(" = ");
- context.append(correlatedTableAlias).append('.').append(quotes.quoted(join.getSourceName()));
-
- if (it.hasNext()) {
- context.append(" AND");
- }
- }
-
- context.append(")");
-
- return false;
- }
-
- @Override
- public boolean visitMemberOf(EJBQLExpression expression) {
-
- // create a correlated subquery, using the following transformation:
-
- // * Subquery Root is always an entity that is a target of relationship
- // * A subquery has a join based on reverse relationship, pointing to
- // the
- // original ID.
- // * Join must be translated as a part of the subquery WHERE clause
- // instead of
- // FROM.
- // * A condition is added: subquery_root_id = LHS_memberof
-
- if (expression.getChildrenCount() != 2) {
- throw new EJBQLException("MEMBER OF must have exactly two children, got: " + expression.getChildrenCount());
- }
-
- if (!(expression.getChild(1) instanceof EJBQLPath)) {
- throw new EJBQLException("Second child of the MEMBER OF must be a collection path, got: "
- + expression.getChild(1));
- }
-
-
- EJBQLPath path = (EJBQLPath) expression.getChild(1);
-
- // make sure the ID for the path does not overlap with other condition
- // joins...
- String id = path.getAbsolutePath();
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String correlatedEntityId = path.getId();
- ClassDescriptor correlatedEntityDescriptor = context.getEntityDescriptor(correlatedEntityId);
- DbEntity correlatedDbEntity = correlatedEntityDescriptor.getEntity().getDbEntity();
- String correlatedTableName = quotes.quotedFQN(correlatedDbEntity.getCatalog(), correlatedDbEntity.getSchema(),
- correlatedDbEntity.getName());
- String correlatedTableAlias = context.getTableAlias(correlatedEntityId, correlatedTableName);
-
- String subqueryId = context.createIdAlias(id);
- ClassDescriptor targetDescriptor = context.getEntityDescriptor(subqueryId);
-
- if (expression.isNegated()) {
- context.append(" NOT");
- }
-
- context.append(" EXISTS (SELECT 1 FROM ");
-
- DbEntity subqueryDbEntity = targetDescriptor.getEntity().getDbEntity();
- String subqueryTableName = quotes.quotedFQN(subqueryDbEntity.getCatalog(), subqueryDbEntity.getSchema(),
- subqueryDbEntity.getName());
- String subqueryRootAlias = context.getTableAlias(subqueryId, subqueryTableName);
-
- ObjRelationship relationship = correlatedEntityDescriptor.getEntity().getRelationship(path.getRelativePath());
-
- if (relationship.getDbRelationshipPath().length() > 1) {
- // if the DbRelationshipPath contains '.', the relationship is flattened
- subqueryRootAlias = processFlattenedRelationShip(subqueryRootAlias, relationship);
- } else {
- // not using "AS" to separate table name and alias name - OpenBase
- // doesn't
- // support "AS", and the rest of the databases do not care
- context.append(subqueryTableName).append(' ').append(subqueryRootAlias);
-
- }
-
- context.append(" WHERE");
-
- DbRelationship correlatedJoinRelationship = context.getIncomingRelationships(new EJBQLTableId(id)).get(0);
-
- for (DbJoin join : correlatedJoinRelationship.getJoins()) {
- context.append(' ').append(subqueryRootAlias).append('.').append(join.getTargetName()).append(" = ");
- context.append(correlatedTableAlias).append('.').append(quotes.quoted(join.getSourceName()));
- context.append(" AND");
- }
-
- // translate subquery_root_id = LHS_of_memberof
- EJBQLEquals equals = new EJBQLEquals(-1);
- EJBQLIdentificationVariable identifier = new EJBQLIdentificationVariable(-1);
- identifier.setText(subqueryId);
- equals.jjtAddChild(identifier, 0);
- equals.jjtAddChild((Node) expression.getChild(0), 1);
- equals.visit(this);
-
- context.append(")");
-
- return false;
- }
-
- private String processFlattenedRelationShip(String subqueryRootAlias, ObjRelationship relationship) {
-
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- List<DbRelationship> dbRelationships = relationship.getDbRelationships();
- // reverse order to get the nearest to the correlated of the direct
- // relation
- for (int i = dbRelationships.size() - 1; i > 0; i--) {
- DbRelationship dbRelationship = dbRelationships.get(i);
- DbEntity subqueryTargetEntity = dbRelationship.getTargetEntity();
- String subqueryTargetTableName = quotes.quotedFQN(subqueryTargetEntity.getCatalog(),
- subqueryTargetEntity.getSchema(), subqueryTargetEntity.getName());
- String subqueryTargetAlias;
- if (i == dbRelationships.size() - 1) {
- subqueryTargetAlias = subqueryRootAlias;
- context.append(subqueryTargetTableName).append(' ').append(subqueryTargetAlias);
- } else {
- subqueryTargetAlias = context.getTableAlias(subqueryTargetTableName, subqueryTargetTableName);
- }
-
- context.append(" JOIN ");
-
- DbEntity subquerySourceEntity = dbRelationship.getSourceEntity();
- String subquerySourceTableName = quotes.quotedFQN(subquerySourceEntity.getCatalog(),
- subquerySourceEntity.getSchema(), subquerySourceEntity.getName());
- String subquerySourceAlias = context.getTableAlias(subquerySourceTableName, subquerySourceTableName);
-
- context.append(subquerySourceTableName).append(' ').append(subquerySourceAlias);
-
- context.append(" ON (");
-
- List<DbJoin> joins = dbRelationship.getJoins();
- Iterator<DbJoin> it = joins.iterator();
- while (it.hasNext()) {
- DbJoin join = it.next();
- context.append(' ').append(subqueryTargetAlias).append('.').append(join.getTargetName()).append(" = ");
- context.append(subquerySourceAlias).append('.').append(join.getSourceName());
- if (it.hasNext()) {
- context.append(" AND");
- }
- }
- context.append(" )");
- subqueryRootAlias = subquerySourceAlias;
-
- }
- return subqueryRootAlias;
- }
-
- @Override
- public boolean visitAll(EJBQLExpression expression) {
- context.append(" ALL");
- return true;
- }
-
- @Override
- public boolean visitAny(EJBQLExpression expression) {
- context.append(" ANY");
- return true;
- }
-
- @Override
- public boolean visitOr(EJBQLExpression expression, int finishedChildIndex) {
- visitConditional((AggregateConditionNode) expression, " OR", finishedChildIndex);
- return true;
- }
-
- /**
- * Checks expression for containing null input parameter. For that, we'll
- * append IS NULL or IS NOT NULL instead of =null or <>null
- *
- * @return whether replacement was done and there's no need for normal
- * expression processing
- */
- protected boolean checkNullParameter(EJBQLExpression expression, String toAppend) {
- if (expression.getChildrenCount() == 2) {
- // We rewrite expression "parameter = :x" where x=null
- // as "parameter IS NULL"
- // BUT in such as ":x = parameter" (where x=null) we don't do
- // anything
- // as a result it can be unsupported in some DB
- if (expression.getChild(1) instanceof EJBQLNamedInputParameter par) {
- if (context.namedParameters.containsKey(par.getText())
- && context.namedParameters.get(par.getText()) == null) {
- context.append(toAppend);
- return true;
- }
- } else if (expression.getChild(1) instanceof EJBQLPositionalInputParameter par) {
- if (context.positionalParameters.containsKey(par.getPosition())
- && context.positionalParameters.get(par.getPosition()) == null) {
- context.append(toAppend);
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean visitEquals(EJBQLExpression expression, int finishedChildIndex) {
- switch (finishedChildIndex) {
- case 0:
- if (checkNullParameter(expression, " IS NULL")) {
- return false;
- }
- context.append(" =");
- break;
- case 1:
- // check multicolumn match condition and undo op insertion and
- // append it
- // from scratch if needed
- if (multiColumnOperands != null) {
-
- if (multiColumnOperands.size() != 2) {
- throw new EJBQLException(
- "Invalid multi-column equals expression. Expected 2 multi-column operands, got "
- + multiColumnOperands.size());
- }
-
- context.trim(2);
-
- EJBQLMultiColumnOperand lhs = multiColumnOperands.get(0);
- EJBQLMultiColumnOperand rhs = multiColumnOperands.get(1);
-
- Iterator<?> it = lhs.getKeys().iterator();
- while (it.hasNext()) {
- Object key = it.next();
-
- lhs.appendValue(key);
- context.append(" =");
- rhs.appendValue(key);
-
- if (it.hasNext()) {
- context.append(" AND");
- }
- }
-
- multiColumnOperands = null;
- }
-
- break;
- }
-
- return true;
- }
-
- @Override
- public boolean visitNamedInputParameterForIn(EJBQLExpression expression) {
- List<String> parameters = context.bindNamedParameterFlatteningCollection(expression.getText());
-
- if(0==parameters.size()) {
- throw new IllegalStateException("it is not possible for a named parameter to not be bound");
- }
-
- for(int i=0;i<parameters.size();i++) {
- if(0!=i) {
- context.append(',');
- }
-
- processParameter(parameters.get(i), expression);
- }
-
- return true;
- }
-
- @Override
- public boolean visitNamedInputParameter(EJBQLExpression expression) {
- String parameter = context.bindNamedParameter(expression.getText());
- processParameter(parameter, expression);
- return true;
- }
-
- @Override
- public boolean visitNot(EJBQLExpression expression) {
- context.append(" NOT");
- return true;
- }
-
- @Override
- public boolean visitNotEquals(EJBQLExpression expression, int finishedChildIndex) {
- switch (finishedChildIndex) {
- case 0:
- if (checkNullParameter(expression, " IS NOT NULL")) {
- return false;
- }
- context.append(" <>");
- break;
- case 1:
- // check multicolumn match condition and undo op insertion and
- // append it
- // from scratch if needed
- if (multiColumnOperands != null) {
-
- if (multiColumnOperands.size() != 2) {
- throw new EJBQLException(
- "Invalid multi-column equals expression. Expected 2 multi-column operands, got "
- + multiColumnOperands.size());
- }
-
- context.trim(3);
-
- EJBQLMultiColumnOperand lhs = multiColumnOperands.get(0);
- EJBQLMultiColumnOperand rhs = multiColumnOperands.get(1);
-
- Iterator<?> it = lhs.getKeys().iterator();
- while (it.hasNext()) {
- Object key = it.next();
-
- lhs.appendValue(key);
- context.append(" <>");
- rhs.appendValue(key);
-
- if (it.hasNext()) {
- context.append(" OR");
- }
- }
-
- multiColumnOperands = null;
- }
-
- break;
- }
- return true;
- }
-
- @Override
- public boolean visitGreaterThan(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- context.append(" >");
- }
-
- return true;
- }
-
- @Override
- public boolean visitGreaterOrEqual(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- context.append(" >=");
- }
-
- return true;
- }
-
- @Override
- public boolean visitLessOrEqual(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- context.append(" <=");
- }
-
- return true;
- }
-
- @Override
- public boolean visitLessThan(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- context.append(" <");
- }
-
- return true;
- }
-
- @Override
- public boolean visitLike(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- if (checkNullParameter(expression, " IS NULL")) {
- return false;
- }
-
- if (expression.isNegated()) {
- context.append(" NOT");
- }
- context.append(" LIKE");
- }
-
- return true;
- }
-
- @Override
- public boolean visitIn(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- if (expression.isNegated()) {
- context.append(" NOT");
- }
- context.append(" IN");
-
- // a cosmetic hack for preventing extra pair of parenthesis from
- // being
- // appended in 'visitSubselect'
- if (expression.getChildrenCount() == 2 && expression.getChild(1) instanceof EJBQLSubselect) {
- visitSubselect(expression.getChild(1));
- return false;
- }
-
- context.append(" (");
- } else if (finishedChildIndex == expression.getChildrenCount() - 1) {
- context.append(")");
- } else if (finishedChildIndex > 0) {
- context.append(',');
- }
-
- return true;
- }
-
- /**
- * Visits conditional node, suppling brackets if needed
- */
- void visitConditional(AggregateConditionNode e, String afterText, int childIndex) {
- if (childIndex == -1 && needBracket(e)) {
- context.append(" (");
- }
-
- afterChild(e, afterText, childIndex);
-
- if (childIndex == e.getChildrenCount() - 1 && needBracket(e)) {
- context.append(")");
- }
- }
-
- /**
- * Checks whether expression needs to be rounded by brackets
- */
- boolean needBracket(AggregateConditionNode e) {
- return (e.jjtGetParent() instanceof AggregateConditionNode)
- && e.getPriority() > ((AggregateConditionNode) e.jjtGetParent()).getPriority();
- }
-
- protected void afterChild(EJBQLExpression e, String text, int childIndex) {
- if (childIndex >= 0) {
- if (childIndex + 1 < e.getChildrenCount()) {
- context.append(text);
- }
- }
- }
-
- @Override
- public boolean visitIdentificationVariable(EJBQLExpression expression) {
- // this is a match on a variable, like "x = :x"
-
- ClassDescriptor descriptor = context.getEntityDescriptor(expression.getText());
- if (descriptor == null) {
- throw new EJBQLException("Invalid identification variable: " + expression.getText());
- }
-
- DbEntity table = descriptor.getEntity().getDbEntity();
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = context.getTableAlias(expression.getText(),
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- Collection<DbAttribute> pks = table.getPrimaryKeys();
-
- if (pks.size() == 1) {
- DbAttribute pk = pks.iterator().next();
- context.append(' ').append(alias).append('.').append(quotes.quoted(pk.getName()));
- } else {
- throw new EJBQLException("Multi-column PK to-many matches are not yet supported.");
- }
- return false;
- }
-
- @Override
- public boolean visitDbPath(EJBQLExpression expression, int finishedChildIndex) {
- expression.visit(new EJBQLDbPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- EJBQLConditionTranslator.this.addMultiColumnOperand(operand);
- }
- });
- return false;
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- expression.visit(new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- EJBQLConditionTranslator.this.addMultiColumnOperand(operand);
- }
- });
- return false;
- }
-
- @Override
- public boolean visitIntegerLiteral(EJBQLIntegerLiteral expression) {
- if (expression.getText() == null) {
- context.append("null");
- } else {
-
- String text = expression.getText();
-
- if (expression.isNegative() && text != null) {
- if (text.startsWith("-")) {
- text = text.substring(1);
- } else {
- text = "-" + text;
- }
- }
-
- Long longValue;
-
- try {
- longValue = Long.valueOf(text);
- } catch (NumberFormatException nfex) {
- throw new EJBQLException("Invalid integer: " + expression.getText());
- }
-
- if(longValue > Integer.MAX_VALUE) {
- String var = context.bindParameter(longValue);
- context.append(" #bind($").append(var).append(" 'BIGINT')");
- }
- else {
- String var = context.bindParameter(longValue.intValue());
- context.append(" #bind($").append(var).append(" 'INTEGER')");
- }
- }
- return true;
- }
-
- @Override
- public boolean visitDecimalLiteral(EJBQLDecimalLiteral expression) {
- if (expression.getText() == null) {
- context.append("null");
- } else {
-
- String text = expression.getText();
-
- if (expression.isNegative() && text != null) {
- if (text.startsWith("-")) {
- text = text.substring(1);
- } else {
- text = "-" + text;
- }
- }
-
- Object value;
-
- try {
- value = new BigDecimal(text);
- } catch (NumberFormatException nfex) {
- throw new EJBQLException("Invalid decimal: " + expression.getText());
- }
-
- String var = context.bindParameter(value);
- context.append(" #bind($").append(var).append(" 'DECIMAL')");
- }
- return true;
- }
-
- @Override
- public boolean visitEscapeCharacter(EJBQLExpression expression) {
- // note that EscapeChar text is already wrapped in single quotes
- context.append(" ESCAPE ").append(expression.getText());
- return false;
- }
-
- @Override
- public boolean visitIsNull(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- context.append(expression.isNegated() ? " IS NOT NULL" : " IS NULL");
- }
-
- return true;
- }
-
- @Override
- public boolean visitPositionalInputParameterForIn(EJBQLPositionalInputParameter expression) {
- List<String> parameters = context.bindPositionalParameterFlatteningCollection(expression.getPosition());
-
- if(0==parameters.size()) {
- throw new IllegalStateException("it is not possible for a positional parameter to not be bound");
- }
-
- for(int i=0;i<parameters.size();i++) {
- if(0!=i) {
- context.append(',');
- }
-
- processParameter(parameters.get(i), expression);
- }
-
- return true;
- }
-
- @Override
- public boolean visitPositionalInputParameter(EJBQLPositionalInputParameter expression) {
-
- String parameter = context.bindPositionalParameter(expression.getPosition());
- processParameter(parameter, expression);
- return true;
- }
-
- @Override
- public boolean visitBooleanLiteral(EJBQLExpression expression) {
- if (expression.getText() == null) {
- context.append("null");
- } else {
- Object value = Boolean.valueOf(expression.getText());
- String var = context.bindParameter(value);
- context.append(" #bind($").append(var).append(" 'BOOLEAN')");
- }
-
- return true;
- }
-
- @Override
- public boolean visitStringLiteral(EJBQLExpression expression) {
- if (expression.getText() == null) {
- context.append("null");
- } else {
- // note that String Literal text is already wrapped in single
- // quotes, with
- // quotes that are part of the string escaped.
- context.append(" #bind(").append(expression.getText()).append(" 'VARCHAR')");
- }
- return true;
- }
-
- @Override
- public boolean visitSubselect(EJBQLExpression expression) {
- context.onSubselect();
- context.append(" (");
- expression.visit(new EJBQLSelectTranslator(context));
- context.append(')');
- return false;
- }
-
- private void processParameter(String boundName, EJBQLExpression expression) {
- Object object = context.getBoundParameter(boundName);
-
- Map<?, ?> map = null;
- if (object instanceof Persistent persistent) {
- map = persistent.getObjectId().getIdSnapshot();
- } else if (object instanceof ObjectId objectId) {
- map = objectId.getIdSnapshot();
- } else if (object instanceof Map<?, ?> objectAsMap) {
- map = objectAsMap;
- }
-
- if (map != null) {
- if (map.size() == 1) {
- context.rebindParameter(boundName, map.values().iterator().next());
- } else {
- addMultiColumnOperand(EJBQLMultiColumnOperand.getObjectOperand(context, map));
- return;
- }
- }
-
- if (object != null) {
- context.append(" #bind($").append(boundName).append(")");
- } else {
-
- String type = null;
- Node parent = ((SimpleNode) expression).jjtGetParent();
-
- context.pushMarker("@processParameter", true);
-
- EJBQLPathAnaliserTranslator translator = new EJBQLPathAnaliserTranslator(context);
- parent.visit(translator);
- translator.visitPath(parent, parent.getChildrenCount());
-
- String id = translator.idPath;
- if (id != null) {
-
- ClassDescriptor descriptor = context.getEntityDescriptor(id);
- if (descriptor == null) {
- throw new EJBQLException("Unmapped id variable: " + id);
- }
- String pathChunk = translator.lastPathComponent;
-
- PropertyDescriptor property = descriptor.getProperty(pathChunk);
- if (property instanceof AttributeProperty) {
- String atrType = ((AttributeProperty) property).getAttribute().getType();
-
- type = TypesMapping.getSqlNameByType(TypesMapping.getSqlTypeByJava(atrType));
- }
- }
- context.popMarker();
-
- if (type == null) {
- type = "VARCHAR";
- }
- // this is a hack to prevent exceptions on DB's like Derby for
- // expressions
- // "X = NULL". The 'VARCHAR' parameter is totally bogus, but seems
- // to work on
- // all tested DB's... Also note what JPA spec, chapter 4.11 says:
- // "Comparison
- // or arithmetic operations with a NULL value always yield an
- // unknown value."
-
- // TODO: andrus 6/28/2007 Ideally we should track the type of the
- // current
- // expression to provide a meaningful type.
-
- context.append(" #bind($").append(boundName).append(" '" + type + "')");
- }
- }
-
- @Override
- public boolean visitAdd(EJBQLExpression expression, int finishedChildIndex) {
-
- switch (finishedChildIndex) {
- case -1:
- context.append(" (");
- break;
- case 0:
- context.append(" +");
- break;
-
- case 1:
- context.append(")");
- break;
- }
-
- return true;
- }
-
- @Override
- public boolean visitSubtract(EJBQLExpression expression, int finishedChildIndex) {
-
- switch (finishedChildIndex) {
- case -1:
- context.append(" (");
- break;
- case 0:
- context.append(" -");
- break;
-
- case 1:
- context.append(")");
- break;
- }
-
- return true;
- }
-
- @Override
- public boolean visitMultiply(EJBQLExpression expression, int finishedChildIndex) {
- switch (finishedChildIndex) {
- case -1:
- context.append(" (");
- break;
- case 0:
- context.append(" *");
- break;
-
- case 1:
- context.append(")");
- break;
- }
-
- return true;
- }
-
- @Override
- public boolean visitDivide(EJBQLExpression expression, int finishedChildIndex) {
- switch (finishedChildIndex) {
- case -1:
- context.append(" (");
- break;
- case 0:
- context.append(" /");
- break;
-
- case 1:
- context.append(")");
- break;
- }
-
- return true;
- }
-
- @Override
- public boolean visitCurrentDate(EJBQLExpression expression) {
- context.append(" {fn CURDATE()}");
- return false;
- }
-
- @Override
- public boolean visitCurrentTime(EJBQLExpression expression) {
- context.append(" {fn CURTIME()}");
- return false;
- }
-
- @Override
- public boolean visitCurrentTimestamp(EJBQLExpression expression) {
- context.append(" {fn NOW()}");
- return false;
- }
-
- @Override
- public boolean visitAbs(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn ABS(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- }
-
- return true;
- }
-
- @Override
- public boolean visitSqrt(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn SQRT(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- }
-
- return true;
- }
-
- @Override
- public boolean visitMod(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn MOD(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- } else {
- context.append(',');
- }
-
- return true;
- }
-
- @Override
- public boolean visitConcat(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn CONCAT(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- } else {
- context.append(',');
- }
-
- return true;
- }
-
- @Override
- public boolean visitSubstring(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn SUBSTRING(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- } else {
- context.append(',');
- }
-
- return true;
- }
-
- @Override
- public boolean visitLower(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn LCASE(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- }
-
- return true;
- }
-
- @Override
- public boolean visitUpper(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn UCASE(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- }
-
- return true;
- }
-
- @Override
- public boolean visitLength(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn LENGTH(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- }
-
- return true;
- }
-
- @Override
- public boolean visitLocate(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn LOCATE(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- } else {
- context.append(',');
- }
-
- return true;
- }
-
- @Override
- public boolean visitTrim(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
-
- if (!(expression.getChild(0) instanceof EJBQLTrimSpecification)) {
- context.append(" {fn LTRIM({fn RTRIM(");
- }
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- if (!(expression.getChild(0) instanceof EJBQLTrimSpecification)
- || expression.getChild(0) instanceof EJBQLTrimBoth) {
- context.append(")})}");
- } else {
- context.append(")}");
- }
- }
-
- return true;
- }
-
- @Override
- public boolean visitTrimCharacter(EJBQLExpression expression) {
- // this is expected to be overwritten in adapter-specific translators
- if (!"' '".equals(expression.getText())) {
- throw new UnsupportedOperationException(
- "TRIM character other than space is not supported by a generic adapter: " + expression.getText());
- }
-
- return false;
- }
-
- @Override
- public boolean visitTrimLeading(EJBQLExpression expression) {
- context.append(" {fn LTRIM(");
- return false;
- }
-
- @Override
- public boolean visitTrimTrailing(EJBQLExpression expression) {
- context.append(" {fn RTRIM(");
- return false;
- }
-
- @Override
- public boolean visitTrimBoth(EJBQLExpression expression) {
- context.append(" {fn LTRIM({fn RTRIM(");
- return false;
- }
-
-}
-
-class EJBQLPathAnaliserTranslator extends EJBQLPathTranslator {
-
- private boolean isPath;
-
- public EJBQLPathAnaliserTranslator(EJBQLTranslationContext context) {
- super(context);
- isPath = false;
- }
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
- if (isPath) {
- return false;
- } else {
-
- if (finishedChildIndex > 0) {
-
- if (finishedChildIndex + 1 < expression.getChildrenCount()) {
- processIntermediatePathComponent();
- } else {
- processLastPathComponent();
- if (idPath != null && lastPathComponent != null) {
- isPath = true;
- }
- return false;
- }
- }
- }
- return true;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDbPathTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDbPathTranslator.java
deleted file mode 100644
index efffe436a..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDbPathTranslator.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class EJBQLDbPathTranslator extends EJBQLBaseVisitor {
-
- private final EJBQLTranslationContext context;
- protected DbEntity currentEntity;
- private String lastPathComponent;
- protected String lastAlias;
- protected String idPath;
- protected String joinMarker;
- private String fullPath;
- private boolean usingAliases;
-
- public EJBQLDbPathTranslator(EJBQLTranslationContext context) {
- super(true);
- this.context = context;
- this.usingAliases = true;
- }
-
- protected abstract void appendMultiColumnPath(EJBQLMultiColumnOperand operand);
-
- @Override
- public boolean visitDbPath(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex > 0) {
-
- if (finishedChildIndex + 1 < expression.getChildrenCount()) {
- processIntermediatePathComponent();
- } else {
- processLastPathComponent();
- }
- }
-
- return true;
- }
-
- @Override
- public boolean visitIdentifier(EJBQLExpression expression) {
-
- // expression id is always rooted in an ObjEntity, even for DbPath...
- ClassDescriptor descriptor = context.getEntityDescriptor(expression.getText());
- if (descriptor == null) {
- throw new EJBQLException("Invalid identification variable: " + expression.getText());
- }
-
- this.currentEntity = descriptor.getEntity().getDbEntity();
- this.idPath = expression.getText();
- this.joinMarker = EJBQLJoinAppender.makeJoinTailMarker(idPath);
- this.fullPath = idPath;
- return true;
- }
-
- @Override
- public boolean visitIdentificationVariable(EJBQLExpression expression) {
-
- // TODO: andrus 6/11/2007 - if the path ends with relationship, the last
- // join will
- // get lost...
- if (lastPathComponent != null) {
- resolveJoin(true);
- }
-
- this.lastPathComponent = expression.getText();
- return true;
- }
-
- private void resolveJoin(boolean inner) {
-
- EJBQLJoinAppender joinAppender = context.getTranslator().getJoinAppender(context);
-
- // TODO: andrus 1/6/2007 - conflict with object path naming... maybe
- // 'registerReusableJoin' should normalize everything to a db path?
- String newPath = idPath + '.' + lastPathComponent;
- String oldPath = joinAppender.registerReusableJoin(idPath, lastPathComponent, newPath);
-
- this.fullPath = fullPath + '.' + lastPathComponent;
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- if (oldPath != null) {
- this.idPath = oldPath;
- this.lastAlias = context.getTableAlias(oldPath,
- quotes.quotedFQN(currentEntity.getCatalog(), currentEntity.getSchema(), currentEntity.getName()));
- } else {
-
- // register join
- if (inner) {
- joinAppender.appendInnerJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
- this.lastAlias = context.getTableAlias(fullPath,
- quotes.quotedFQN(currentEntity.getCatalog(), currentEntity.getSchema(),
- currentEntity.getName()));
- } else {
- joinAppender.appendOuterJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
-
- DbRelationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
- DbEntity targetEntity = lastRelationship.getTargetEntity();
-
- this.lastAlias = context.getTableAlias(fullPath,
- quotes.quotedFQN(targetEntity.getCatalog(), targetEntity.getSchema(), targetEntity.getName()));
- }
-
- this.idPath = newPath;
- }
- }
-
- private void processIntermediatePathComponent() {
- DbRelationship relationship = currentEntity.getRelationship(lastPathComponent);
- if (relationship == null) {
- throw new EJBQLException("Unknown relationship '" + lastPathComponent + "' for entity '"
- + currentEntity.getName() + "'");
- }
-
- this.currentEntity = relationship.getTargetEntity();
- }
-
- private void processLastPathComponent() {
-
- DbAttribute attribute = currentEntity.getAttribute(lastPathComponent);
-
- if (attribute != null) {
- processTerminatingAttribute(attribute);
- return;
- }
-
- DbRelationship relationship = currentEntity.getRelationship(lastPathComponent);
- if (relationship != null) {
- processTerminatingRelationship(relationship);
- return;
- }
-
- throw new IllegalStateException("Invalid path component: " + lastPathComponent);
- }
-
- protected void processTerminatingAttribute(DbAttribute attribute) {
-
- DbEntity table = attribute.getEntity();
- QuotingStrategy quotes = context.getIdentifierQuotes();
-
- if (isUsingAliases()) {
- String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
- context.append(' ').append(alias).append('.').append(quotes.quoted(attribute.getName()));
- } else {
- context.append(' ').append(quotes.quoted(attribute.getName()));
- }
- }
-
- protected void processTerminatingRelationship(DbRelationship relationship) {
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- if (relationship.isToMany()) {
-
- // use an outer join for to-many matches
- resolveJoin(false);
-
- DbEntity table = relationship.getTargetEntity();
-
- String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- Collection<DbAttribute> pks = table.getPrimaryKeys();
-
- if (pks.size() == 1) {
- DbAttribute pk = pks.iterator().next();
- context.append(' ');
- if (isUsingAliases()) {
- context.append(alias).append('.');
- }
- context.append(quotes.quoted(pk.getName()));
- } else {
- throw new EJBQLException("Multi-column PK to-many matches are not yet supported.");
- }
- } else {
- // match FK against the target object
-
- DbEntity table = relationship.getSourceEntity();
-
- String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- List<DbJoin> joins = relationship.getJoins();
-
- if (joins.size() == 1) {
- DbJoin join = joins.getFirst();
- context.append(' ');
- if (isUsingAliases()) {
- context.append(alias).append('.');
- }
- context.append(quotes.quoted(join.getSource().getName()));
- } else {
- Map<String, String> multiColumnMatch = new HashMap<>(joins.size() + 2);
-
- for (DbJoin join : joins) {
- String column = isUsingAliases() ? alias + "." + join.getSourceName() : join.getSourceName();
-
- multiColumnMatch.put(join.getTargetName(), column);
- }
-
- appendMultiColumnPath(EJBQLMultiColumnOperand.getPathOperand(context, multiColumnMatch));
- }
- }
- }
-
- public boolean isUsingAliases() {
- return usingAliases;
- }
-
- public void setUsingAliases(boolean usingAliases) {
- this.usingAliases = usingAliases;
- }
-
- protected void resolveJoin() {
-
- EJBQLJoinAppender joinAppender = context.getTranslator().getJoinAppender(context);
-
- String newPath = idPath + '.' + lastPathComponent;
- String oldPath = joinAppender.registerReusableJoin(idPath, lastPathComponent, newPath);
-
- this.fullPath = fullPath + '.' + lastPathComponent;
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- if (oldPath != null) {
- this.idPath = oldPath;
- DbRelationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
- if (lastRelationship != null) {
- DbEntity targetEntity = lastRelationship.getTargetEntity();
-
- this.lastAlias = context.getTableAlias(fullPath,
- quotes.quotedFQN(targetEntity.getCatalog(), targetEntity.getSchema(), targetEntity.getName()));
- } else {
- String tableName = quotes.quotedFQN(currentEntity.getCatalog(), currentEntity.getSchema(),
- currentEntity.getName());
- this.lastAlias = context.getTableAlias(oldPath, tableName);
- }
- } else {
- DbRelationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
-
- DbEntity targetEntity;
- if (lastRelationship != null) {
- targetEntity = lastRelationship.getTargetEntity();
- } else {
- targetEntity = currentEntity;
- }
-
- // register join
- joinAppender.appendInnerJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
- // TODO: outer joins handling
-
- this.lastAlias = context.getTableAlias(fullPath,
- quotes.quotedFQN(targetEntity.getCatalog(), targetEntity.getSchema(), targetEntity.getName()));
-
- this.idPath = newPath;
- }
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDeleteTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDeleteTranslator.java
deleted file mode 100644
index 4e3805e95..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLDeleteTranslator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-/**
- * A translator of EJBQL DELETE statements into SQL.
- *
- * @since 3.0
- */
-public class EJBQLDeleteTranslator extends EJBQLBaseVisitor {
-
- protected EJBQLTranslationContext context;
-
- public EJBQLDeleteTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- @Override
- public boolean visitDelete(EJBQLExpression expression) {
- context.append("DELETE");
- return true;
- }
-
- @Override
- public boolean visitFrom(EJBQLExpression expression, int finishedChildIndex) {
- context.append(" FROM");
- expression.visit(context.getTranslator().getFromTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitWhere(EJBQLExpression expression) {
- context.append(" WHERE");
- expression.visit(context.getTranslator().getConditionTranslator(context));
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLFromTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLFromTranslator.java
deleted file mode 100644
index 3205ce10a..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLFromTranslator.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.parser.EJBQLFromItem;
-import org.apache.cayenne.ejbql.parser.EJBQLJoin;
-
-/**
- * @since 3.0
- */
-public class EJBQLFromTranslator extends EJBQLBaseVisitor {
-
- protected EJBQLTranslationContext context;
- private String lastId;
- private EJBQLJoinAppender joinAppender;
-
- public EJBQLFromTranslator(EJBQLTranslationContext context) {
- super(true);
- this.context = context;
- this.joinAppender = context.getTranslator().getJoinAppender(context);
- }
-
- @Override
- public boolean visitFrom(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- if (lastId != null) {
- context.markCurrentPosition(EJBQLJoinAppender.makeJoinTailMarker(lastId));
- }
- }
-
- return true;
- }
-
- @Override
- public boolean visitFromItem(EJBQLFromItem expression, int finishedChildIndex) {
-
- String id = expression.getId();
-
- if (lastId != null) {
- context.append(',');
- context.markCurrentPosition(EJBQLJoinAppender.makeJoinTailMarker(lastId));
- }
-
- this.lastId = id;
- joinAppender.appendTable(new EJBQLTableId(id));
- return false;
- }
-
- @Override
- public boolean visitInnerFetchJoin(EJBQLJoin join) {
- joinAppender.appendInnerJoin(
- null,
- new EJBQLTableId(join.getLeftHandSideId()),
- new EJBQLTableId(join.getRightHandSideId()));
-
- context.markCurrentPosition(EJBQLJoinAppender
- .makeJoinTailMarker(join.getRightHandSideId()));
- return false;
- }
-
- @Override
- public boolean visitInnerJoin(EJBQLJoin join) {
- joinAppender.appendInnerJoin(
- null,
- new EJBQLTableId(join.getLeftHandSideId()),
- new EJBQLTableId(join.getRightHandSideId()));
-
- //fix 1341-mark current join position for probable future joins to this join
- context.markCurrentPosition(EJBQLJoinAppender.makeJoinTailMarker(join.getRightHandSideId()));
- return false;
- }
-
- @Override
- public boolean visitOuterFetchJoin(EJBQLJoin join) {
- joinAppender.appendOuterJoin(
- null,
- new EJBQLTableId(join.getLeftHandSideId()),
- new EJBQLTableId(join.getRightHandSideId()));
-
- context.markCurrentPosition(EJBQLJoinAppender
- .makeJoinTailMarker(join.getRightHandSideId()));
- return false;
- }
-
- @Override
- public boolean visitOuterJoin(EJBQLJoin join) {
- joinAppender.appendOuterJoin(
- null,
- new EJBQLTableId(join.getLeftHandSideId()),
- new EJBQLTableId(join.getRightHandSideId()));
- context.markCurrentPosition(EJBQLJoinAppender.makeJoinTailMarker(join.getRightHandSideId()));
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLGroupByTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLGroupByTranslator.java
deleted file mode 100644
index d4238574e..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLGroupByTranslator.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-/**
- * @since 3.0
- */
-class EJBQLGroupByTranslator extends EJBQLBaseVisitor {
-
- private EJBQLTranslationContext context;
- private int itemCount;
-
- EJBQLGroupByTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- @Override
- public boolean visitIdentifier(EJBQLExpression expression) {
- if (itemCount++ > 0) {
- context.append(',');
- }
-
- expression.visit(context.getTranslator().getIdentifierColumnsTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- if (itemCount++ > 0) {
- context.append(',');
- }
-
- EJBQLExpressionVisitor childVisitor = new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- throw new EJBQLException("Can't GROUP BY on multi-column paths or objects");
- }
-
- @Override
- public boolean visitIdentificationVariable(EJBQLExpression expression) {
-
- String idVariableAbsolutePath = fullPath + "." + expression.getText();
- ClassDescriptor descriptor = context.getEntityDescriptor(idVariableAbsolutePath);
- if (descriptor != null) {
- QuotingStrategy quotes = context.getIdentifierQuotes();
- DbEntity dbEntity = descriptor.getEntity().getDbEntity();
- this.lastAlias = context.getTableAlias(idVariableAbsolutePath,
- quotes.quotedFQN(dbEntity.getCatalog(), dbEntity.getSchema(), dbEntity.getName()));
- }
-
- resolveLastPathComponent(expression.getText());
- this.fullPath = fullPath + '.' + lastPathComponent;
-
- return true;
- }
-
- @Override
- protected void processTerminatingRelationship(ObjRelationship relationship) {
-
- Collection<DbAttribute> dbAttr = ((ObjEntity) relationship.getTargetEntity()).getDbEntity()
- .getAttributes();
-
- DbRelationship dbRelationship = relationship.getDbRelationships().get(0);
- DbEntity table = (DbEntity) dbRelationship.getTargetEntity();
-
- Iterator<DbAttribute> it = dbAttr.iterator();
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- boolean first = true;
- while (it.hasNext()) {
-
- context.append(!first ? ", " : " ");
-
- DbAttribute dbAttribute = it.next();
- context.append(alias).append('.').append(quotes.quoted(dbAttribute.getName()));
-
- first = false;
- }
-
- }
-
- };
-
- expression.visit(childVisitor);
-
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdColumnsTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdColumnsTranslator.java
deleted file mode 100644
index 27c668264..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdColumnsTranslator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Map;
-
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-/**
- * @since 3.0
- */
-class EJBQLIdColumnsTranslator extends EJBQLIdentifierColumnsTranslator {
-
- private EJBQLTranslationContext context;
-
- EJBQLIdColumnsTranslator(EJBQLTranslationContext context) {
- super(context);
- this.context = context;
- }
-
- @Override
- public boolean visitIdentifier(EJBQLExpression expression) {
-
- Map<String, String> fields = null;
- if (context.isAppendingResultColumns()) {
- fields = context.nextEntityResult().fields();
- }
-
- String idVar = expression.getText();
-
- ClassDescriptor descriptor = context.getEntityDescriptor(idVar);
- ObjEntity oe = descriptor.getEntity();
-
- for (ObjAttribute oa : oe.getPrimaryKeys()) {
- DbAttribute t = oe.getDbEntity().getAttribute(oa.getDbAttributeName());
- appendColumn(idVar, oa, t, fields, oa.getType());
- }
-
- return false;
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdentifierColumnsTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdentifierColumnsTranslator.java
deleted file mode 100644
index 19e503306..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLIdentifierColumnsTranslator.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.dba.TypesMapping;
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.PathComponent;
-import org.apache.cayenne.query.PrefetchTreeNode;
-import org.apache.cayenne.reflect.ArcProperty;
-import org.apache.cayenne.reflect.AttributeProperty;
-import org.apache.cayenne.reflect.ClassDescriptor;
-import org.apache.cayenne.reflect.PropertyVisitor;
-import org.apache.cayenne.reflect.ToManyProperty;
-import org.apache.cayenne.reflect.ToOneProperty;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @since 3.0
- */
-class EJBQLIdentifierColumnsTranslator extends EJBQLBaseVisitor {
-
- private EJBQLTranslationContext context;
- private Set<String> columns;
-
- EJBQLIdentifierColumnsTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- @Override
- public boolean visitIdentifier(EJBQLExpression expression) {
-
- Map<String, String> xfields = null;
- if (context.isAppendingResultColumns()) {
- xfields = context.nextEntityResult().fields();
- }
-
- // assign whatever we have to a final ivar so that it can be accessed
- // within
- // the inner class
- final Map<String, String> fields = xfields;
- final String idVar = expression.getText();
-
- // append all table columns ... the trick is to follow the algorithm for
- // describing the fields in the expression compiler, so that we could
- // assign
- // columns labels from FieldResults in the order we encounter them
- // here...
- // TODO: andrus 2008/02/17 - this is a bit of a hack, think of a better
- // solution
-
- ClassDescriptor descriptor = context.getEntityDescriptor(idVar);
-
- // a table reached by the same path is joined only once, no matter how many attributes are
- // mapped to it, otherwise its alias is declared more than once. See CAY-3018.
- final Set<EJBQLTableId> joinedTables = new HashSet<>();
-
- PropertyVisitor visitor = new PropertyVisitor() {
-
- public boolean visitAttribute(AttributeProperty property) {
- ObjAttribute oa = property.getAttribute();
- Iterator<?> dbPathIterator = oa.getDbPathIterator();
-
- EJBQLJoinAppender joinAppender = null;
- String marker = null;
- EJBQLTableId lhsId = new EJBQLTableId(idVar);
-
- while (dbPathIterator.hasNext()) {
- Object pathPart = dbPathIterator.next();
-
- if (pathPart == null) {
- throw new CayenneRuntimeException("ObjAttribute has no component: %s", oa.getName());
- } else if (pathPart instanceof DbRelationship) {
-
- if (marker == null) {
- marker = EJBQLJoinAppender.makeJoinTailMarker(idVar);
- joinAppender = context.getTranslator().getJoinAppender(context);
- }
-
- DbRelationship dr = (DbRelationship) pathPart;
-
- EJBQLTableId rhsId = new EJBQLTableId(lhsId, dr.getName());
- if (joinedTables.add(rhsId)) {
- joinAppender.appendOuterJoin(marker, lhsId, rhsId);
- }
- lhsId = rhsId;
- } else if (pathPart instanceof DbAttribute dbAttribute) {
- appendColumn(idVar, oa, dbAttribute, fields, oa.getType());
- }
- }
- return true;
- }
-
- public boolean visitToMany(ToManyProperty property) {
- visitRelationship(property);
- return true;
- }
-
- public boolean visitToOne(ToOneProperty property) {
- visitRelationship(property);
- return true;
- }
-
- private void visitRelationship(ArcProperty property) {
- ObjRelationship rel = property.getRelationship();
- DbRelationship dbRel = rel.getDbRelationships().get(0);
-
- for (DbJoin join : dbRel.getJoins()) {
- DbAttribute src = join.getSource();
- appendColumn(idVar, null, src, fields);
- }
- }
- };
-
- // EJBQL queries are polymorphic by definition - there is no distinction
- // between
- // inheritance/no-inheritance fetch
- descriptor.visitAllProperties(visitor);
-
- // append id columns ... (some may have been appended already via
- // relationships)
- DbEntity table = descriptor.getEntity().getDbEntity();
- for (DbAttribute pk : table.getPrimaryKeys()) {
- appendColumn(idVar, null, pk, fields);
- }
-
- // append inheritance discriminator columns...
- for (ObjAttribute column : descriptor.getDiscriminatorColumns()) {
- appendColumn(idVar, column, column.getDbAttribute(), fields);
- }
-
- addPrefetchedColumnsIfAny(idVar);
-
- return false;
- }
-
- private void addPrefetchedColumnsIfAny(final String visitedIdentifier) {
- PrefetchTreeNode prefetchTree = context.getCompiledExpression().getPrefetchTree();
- if (prefetchTree != null) {
- for (PrefetchTreeNode prefetch : prefetchTree.adjacentJointNodes()) {
- ClassDescriptor descriptor = context.getEntityDescriptor(prefetch.getEjbqlPathEntityId());
- if (visitedIdentifier.equals(prefetch.getEjbqlPathEntityId())) {
- DbEntity table = descriptor.getRootDbEntities().iterator().next();
- ObjEntity objectEntity = descriptor.getEntity();
- prefetch.setEntityName(objectEntity.getName());
- Expression prefetchExp = ExpressionFactory.pathExp(prefetch.getPath());
- Expression dbPrefetch = objectEntity.translateToDbPath(prefetchExp);
-
- DbRelationship r = null;
- for (PathComponent<DbAttribute, DbRelationship> component : table.resolvePath(dbPrefetch, context
- .getMetadata().getPathSplitAliases())) {
- r = component.getRelationship();
- }
-
- if (r == null) {
- throw new CayenneRuntimeException("Invalid joint prefetch '%s' for entity: %s"
- , prefetch, objectEntity.getName());
- }
-
- for (DbAttribute attribute : r.getTargetEntity().getAttributes()) {
- appendColumn(prefetch.getEjbqlPathEntityId() + "." + prefetch.getPath(), attribute, "",
- prefetch.getPath() + "." + attribute.getName(), null);
- }
- }
- }
- }
- }
-
- public void appendColumn(String identifier, ObjAttribute property, DbAttribute column, Map<String, String> fields) {
- appendColumn(identifier, property, column, fields, null);
- }
-
- public void appendColumn(String identifier, ObjAttribute property, DbAttribute column, Map<String, String> fields,
- String javaType) {
- String columnLabel = "";
- if (context.isAppendingResultColumns()) {
- columnLabel = fields.get(property != null ? property.getDbAttributePath().value() : column.getName());
- }
- appendColumn(identifier, column, columnLabel, columnLabel, javaType);
- }
-
- public void appendColumn(String identifier, DbAttribute column, String columnAlias, String dataRowKey,
- String javaType) {
-
- DbEntity table = column.getEntity();
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = context.getTableAlias(identifier,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
- String columnName = alias + "." + quotes.quoted(column.getName());
-
- Set<String> columns = getColumns();
-
- if (columns.add(columnName)) {
-
- context.append(columns.size() > 1 ? ", " : " ");
-
- if (context.isAppendingResultColumns()) {
- context.append("#result('");
- }
-
- context.append(columnName);
-
- if (context.isAppendingResultColumns()) {
- if (javaType == null) {
- javaType = TypesMapping.getJavaBySqlType(column);
- }
-
- // TODO: andrus 6/27/2007 - the last parameter is an unofficial
- // "jdbcType" pending CAY-813 implementation, switch to #column directive
- context.append("' '").append(javaType).append("' '").append(columnAlias).append("' '")
- .append(dataRowKey).append("' " + column.getType()).append(")");
- }
- }
- }
-
- private Set<String> getColumns() {
-
- if (columns == null) {
- columns = new HashSet<>();
- }
-
- return columns;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLJoinAppender.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLJoinAppender.java
deleted file mode 100644
index 86f73b406..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLJoinAppender.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.EJBQLParserFactory;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.query.EntityResultSegment;
-import org.apache.cayenne.query.ResultSegment;
-import org.apache.cayenne.util.CayenneMapEntry;
-
-/**
- * Handles appending joins to the content buffer at a marked position.
- *
- * @since 3.0
- */
-public class EJBQLJoinAppender {
-
- protected EJBQLTranslationContext context;
- private Map<String, String> reusableJoins;
-
- static String makeJoinTailMarker(String id) {
- return "FROM_TAIL" + id;
- }
-
- public EJBQLJoinAppender(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- /**
- * Registers a "reusable" join, returning a preexisting ID if the join is already
- * registered. Reusable joins are the implicit inner joins that are added as a result
- * of processing of path expressions in SELECT or WHERE clauses. Note that if an
- * implicit INNER join overlaps with an explicit INNER join, both joins are added to
- * the query.
- */
- public String registerReusableJoin(
- String sourceIdPath,
- String relationship,
- String targetId) {
-
- if (reusableJoins == null) {
- reusableJoins = new HashMap<>();
- }
-
- String key = sourceIdPath + ":" + relationship;
-
- String oldId = reusableJoins.put(key, targetId);
- if (oldId != null) {
- // revert back to old id
- reusableJoins.put(key, oldId);
- return oldId;
- }
-
- return null;
- }
-
- public void appendInnerJoin(String marker, EJBQLTableId lhsId, EJBQLTableId rhsId) {
- appendJoin(marker, lhsId, rhsId, "INNER JOIN");
- }
-
- public void appendOuterJoin(String marker, EJBQLTableId lhsId, EJBQLTableId rhsId) {
- appendJoin(marker, lhsId, rhsId, "LEFT OUTER JOIN");
- }
-
- protected void appendJoin(
- String marker,
- EJBQLTableId lhsId,
- EJBQLTableId rhsId,
- String semantics) {
-
- List<DbRelationship> joinRelationships = context.getIncomingRelationships(rhsId);
- if (joinRelationships.isEmpty()) {
- throw new EJBQLException("No join configured for id " + rhsId);
- }
-
- DbRelationship incomingDB = joinRelationships.get(0);
-
- // TODO: andrus, 1/6/2008 - move reusable join check here...
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- DbEntity sourceEntity = incomingDB.getSourceEntity();
- String tableName = quotes.quotedFQN(sourceEntity.getCatalog(), sourceEntity.getSchema(),
- sourceEntity.getName());
-
- String sourceAlias = context.getTableAlias(lhsId.getEntityId(), tableName);
-
- if (marker != null) {
- context.pushMarker(marker, false);
- }
-
- try {
- context.append(" ").append(semantics);
- if (joinRelationships.size() > 1) {
- // if size of relationship list greater than 1,
- // it's a flattened relationship
- context.append(" ");
-
- for (int i = 1; i < joinRelationships.size(); i++) {
- DbRelationship dbRelationship = joinRelationships.get(i);
-
- DbEntity subquerySourceEntity = dbRelationship.getSourceEntity();
- String subquerySourceTableName = quotes.quotedFQN(subquerySourceEntity.getCatalog(),
- subquerySourceEntity.getSchema(), subquerySourceEntity.getName());
- String subquerySourceAlias = context.getTableAlias(
- subquerySourceTableName,
- subquerySourceTableName);
-
- DbEntity subqueryTargetEntity = dbRelationship.getTargetEntity();
- String subqueryTargetTableName = quotes.quotedFQN(subqueryTargetEntity.getCatalog(),
- subqueryTargetEntity.getSchema(), subqueryTargetEntity.getName());
-
- String subqueryTargetAlias;
- if(i==joinRelationships.size()-1){
- // it's the last table alias
- subqueryTargetAlias = context.getTableAlias(rhsId.getEntityId(), subqueryTargetTableName);
- } else {
- subqueryTargetAlias = context.getTableAlias(
- subqueryTargetTableName,
- subqueryTargetTableName);
- }
- if (i == 1) {
- // first apply the joins defined in query
- context.append(subquerySourceTableName).append(' ').append(subquerySourceAlias);
-
- generateJoiningExpression(
- incomingDB,
- sourceAlias,
- subquerySourceAlias);
-
- }
-
- context.append(' ').append(semantics).append(' ');
- context.append(subqueryTargetTableName).append(' ').append(subqueryTargetAlias);
- generateJoiningExpression(
- dbRelationship,
- subquerySourceAlias,
- subqueryTargetAlias);
- }
-
- } else {
- // non-flattened relationship
- String targetAlias = appendTable(rhsId);
- // apply the joins defined in query
- generateJoiningExpression(incomingDB, sourceAlias, targetAlias);
- }
-
- } finally {
- if (marker != null) {
- context.popMarker();
- }
- }
-
- }
-
- private void generateJoiningExpression(
- DbRelationship incomingDB,
- String sourceAlias,
- String targetAlias) {
- context.append(" ON (");
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- Iterator<DbJoin> it = incomingDB.getJoins().iterator();
- if (it.hasNext()) {
- DbJoin dbJoin = it.next();
- context
- .append(sourceAlias)
- .append('.')
- .append(quotes.quoted(dbJoin.getSourceName()))
- .append(" = ")
- .append(targetAlias)
- .append('.')
- .append(quotes.quoted(dbJoin.getTargetName()));
- }
-
- while (it.hasNext()) {
- context.append(" AND ");
- DbJoin dbJoin = it.next();
- context
- .append(sourceAlias)
- .append('.')
- .append(quotes.quoted(dbJoin.getSourceName()))
- .append(" = ")
- .append(targetAlias)
- .append('.')
- .append(quotes.quoted(dbJoin.getTargetName()));
- }
-
- context.append(")");
- }
-
- public String appendTable(EJBQLTableId id) {
-
- DbEntity dbEntity = id.getDbEntity(context);
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String tableName = quotes.quotedFQN(dbEntity.getCatalog(), dbEntity.getSchema(), dbEntity.getName());
-
- String alias;
-
- if (context.isUsingAliases()) {
- // TODO: andrus 1/5/2007 - if the same table is joined more than once, this
- // will create an incorrect alias.
- alias = context.getTableAlias(id.getEntityId(), tableName);
-
- // not using "AS" to separate table name and alias name - OpenBase doesn't
- // support "AS", and the rest of the databases do not care
- context.append(' ').append(tableName).append(' ').append(alias);
-
- generateJoinsForFlattenedAttributes(id);
-
- } else {
- context.append(' ').append(tableName);
- alias = tableName;
- }
-
- // append inheritance qualifier...
- if (id.isPrimaryTable()) {
-
- Expression qualifier = context
- .getEntityDescriptor(id.getEntityId())
- .getEntityQualifier();
-
- if (qualifier != null) {
-
- EJBQLExpression ejbqlQualifier = ejbqlQualifierForEntityAndSubclasses(
- qualifier,
- id.getEntityId());
-
- context.pushMarker(context.makeWhereMarker(), true);
- context.append(" WHERE");
- context.popMarker();
-
- context.pushMarker(context.makeEntityQualifierMarker(), false);
-
- ejbqlQualifier.visit(context
- .getTranslator()
- .getConditionTranslator(context));
-
- context.popMarker();
- }
- }
-
- return alias;
- }
-
- /**
- * Generates Joins statements for those flattened attributes that appear after the
- * FROM clause, e.g. in WHERE, ORDER BY, etc clauses. Flattened attributes of the
- * entity from the SELECT clause are processed earlier and therefore are omitted.
- *
- * @param id table to JOIN id
- */
- private void generateJoinsForFlattenedAttributes(EJBQLTableId id) {
- String entityName = context.getEntityDescriptor(id.getEntityId())
- .getEntity()
- .getName();
- // if the dbPath is not null, all attributes of the entity are processed earlier
- boolean isProcessingOmitted = id.getDbPath() != null;
- String sourceExpression = context.getCompiledExpression().getSource();
-
- List<ResultSegment> resultSetMapping = context.getMetadata().getResultSetMapping();
- for (ResultSegment mapping : resultSetMapping) {
- if (mapping instanceof EntityResultSegment entityResultSegment) {
- if (entityName.equals(entityResultSegment
- .classDescriptor()
- .getEntity()
- .getName())) {
- // if entity is included into SELECT clause, all its attributes are processed earlier
- isProcessingOmitted = true;
- break;
- }
- }
- }
-
- if (!isProcessingOmitted) {
-
- Collection<ObjAttribute> attributes = context.getEntityDescriptor(id.getEntityId())
- .getEntity().getAttributes();
- for (ObjAttribute objAttribute : attributes) {
- if (objAttribute.isFlattened()
- && sourceExpression.contains(id.getEntityId() + "." + objAttribute.getName())) {
- // joins for attribute are generated if it is flattened and appears in original statement
- Iterator<CayenneMapEntry> dbPathIterator = objAttribute.getDbPathIterator();
- while (dbPathIterator.hasNext()) {
- CayenneMapEntry next = dbPathIterator.next();
- if (next instanceof DbRelationship rel) {
- context.append(" LEFT OUTER JOIN ");
- QuotingStrategy quotes = context.getIdentifierQuotes();
- DbEntity targetEntity = rel.getTargetEntity();
- String targetEntityName = quotes.quotedFQN(targetEntity.getCatalog(),
- targetEntity.getSchema(), targetEntity.getName());
- String subqueryTargetAlias = context.getTableAlias(id.getEntityId(), targetEntityName);
- context.append(targetEntityName).append(' ').append(subqueryTargetAlias);
- DbEntity relSourceEntity = rel.getSourceEntity();
- generateJoiningExpression(
- rel,
- context.getTableAlias(id.getEntityId(),
- quotes.quotedFQN(relSourceEntity.getCatalog(),
- relSourceEntity.getSchema(), relSourceEntity.getName())),
- subqueryTargetAlias);
- }
-
- }
- }
- }
- }
- }
-
- private EJBQLExpression ejbqlQualifierForEntityAndSubclasses(Expression qualifier, String entityId) {
- // parser only works on full queries, so prepend a dummy query and then strip it out...
- String ejbqlChunk = qualifier.toEJBQL(entityId);
- EJBQLExpression expression = EJBQLParserFactory.getParser().parse(
- "DELETE FROM DUMMY WHERE " + ejbqlChunk);
-
- final EJBQLExpression[] result = new EJBQLExpression[1];
- expression.visit(new EJBQLBaseVisitor() {
-
- @Override
- public boolean visitWhere(EJBQLExpression expression) {
- result[0] = expression.getChild(0);
- return false;
- }
- });
-
- return result[0];
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLMultiColumnOperand.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLMultiColumnOperand.java
deleted file mode 100644
index 365cfd9a2..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLMultiColumnOperand.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.cayenne.ejbql.EJBQLException;
-
-/**
- * A holder of multi-column match condition operand.
- *
- * @since 3.0
- */
-public abstract class EJBQLMultiColumnOperand {
-
- static EJBQLMultiColumnOperand getPathOperand(
- EJBQLTranslationContext context,
- Map pathMap) {
- return new PathMultiColumnOperand(context, pathMap);
- }
-
- static EJBQLMultiColumnOperand getObjectOperand(
- EJBQLTranslationContext context,
- Map object) {
- return new ObjectMultiColumnOperand(context, object);
- }
-
- EJBQLTranslationContext context;
- Map map;
-
- Collection getKeys() {
- return map.keySet();
- }
-
- abstract void appendValue(Object key);
-
- private static class PathMultiColumnOperand extends EJBQLMultiColumnOperand {
-
- PathMultiColumnOperand(EJBQLTranslationContext context, Map pathMap) {
- this.context = context;
- this.map = pathMap;
- }
-
- @Override
- void appendValue(Object key) {
-
- Object column = map.get(key);
- if (column == null) {
- throw new EJBQLException("Invalid match path, no match for ID column "
- + key);
- }
-
- context.append(' ').append(column.toString());
- }
- }
-
- private static class ObjectMultiColumnOperand extends EJBQLMultiColumnOperand {
-
- ObjectMultiColumnOperand(EJBQLTranslationContext context, Map pathMap) {
- this.context = context;
- this.map = pathMap;
- }
-
- @Override
- void appendValue(Object key) {
- Object value = map.get(key);
- if (value == null) {
- throw new EJBQLException("Invalid object, no match for ID column " + key);
- }
-
- String var = context.bindParameter(value);
- context.append(" #bind($").append(var).append(')');
- }
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
deleted file mode 100644
index 99c3b3c44..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLOrderByTranslator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 3.0
- */
-class EJBQLOrderByTranslator extends EJBQLBaseVisitor {
-
- private EJBQLTranslationContext context;
- private int itemCount;
-
- EJBQLOrderByTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- @Override
- public boolean visitOrderByItem(EJBQLExpression expression) {
- if (itemCount++ > 0) {
- context.append(',');
- }
-
- return true;
- }
-
- @Override
- public boolean visitDescending(EJBQLExpression expression) {
- context.append(" DESC");
- return true;
- }
-
- @Override
- public boolean visitAggregate(EJBQLExpression expression) {
- expression.visit(context.getTranslator().getAggregateColumnTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- EJBQLExpressionVisitor childVisitor = new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- throw new EJBQLException("Can't order on multi-column paths or objects");
- }
- };
- expression.visit(childVisitor);
- return false;
- }
-
- @Override
- public boolean visitDbPath(EJBQLExpression expression, int finishedChildIndex) {
- expression.visit(new EJBQLDbPathTranslator(context) {
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- throw new EJBQLException("Can't order on multi-column paths or objects");
- }
- });
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLPathTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLPathTranslator.java
deleted file mode 100644
index 4d8dc468f..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLPathTranslator.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.exp.path.CayennePath;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.Entity;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-/**
- * A translator that walks the relationship/attribute path, appending joins to
- * the query.
- *
- * @since 3.0
- */
-public abstract class EJBQLPathTranslator extends EJBQLBaseVisitor {
-
- private final EJBQLTranslationContext context;
- protected ObjEntity currentEntity;
- protected String lastPathComponent;
- protected boolean innerJoin;
- protected String lastAlias;
- protected String idPath;
- protected String joinMarker;
- protected String fullPath;
- private boolean usingAliases;
-
- public EJBQLPathTranslator(EJBQLTranslationContext context) {
- super(true);
- this.context = context;
- this.usingAliases = true;
- }
-
- protected abstract void appendMultiColumnPath(EJBQLMultiColumnOperand operand);
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- if (finishedChildIndex > 0) {
-
- if (finishedChildIndex + 1 < expression.getChildrenCount()) {
- processIntermediatePathComponent();
- } else {
- processLastPathComponent();
- }
- }
-
- return true;
- }
-
- @Override
- public boolean visitIdentifier(EJBQLExpression expression) {
- ClassDescriptor descriptor = context.getEntityDescriptor(expression.getText());
- if (descriptor == null) {
- throw new EJBQLException("Invalid identification variable: " + expression.getText());
- }
-
- this.currentEntity = descriptor.getEntity();
- this.idPath = expression.getText();
- this.joinMarker = EJBQLJoinAppender.makeJoinTailMarker(idPath);
- this.fullPath = idPath;
- return true;
- }
-
- @Override
- public boolean visitIdentificationVariable(EJBQLExpression expression) {
-
- // TODO: andrus 6/11/2007 - if the path ends with relationship, the last join will get lost...
- if (lastPathComponent != null) {
- resolveJoin();
- }
-
- resolveLastPathComponent(expression.getText());
- return true;
- }
-
- /**
- * @since 4.0
- */
- protected void resolveLastPathComponent(String pathComponent) {
-
- if (pathComponent.endsWith(Entity.OUTER_JOIN_INDICATOR)) {
- this.lastPathComponent = pathComponent.substring(0, pathComponent.length() - 1);
- this.innerJoin = false;
- } else {
- this.lastPathComponent = pathComponent;
- this.innerJoin = true;
- }
- }
-
- protected void resolveJoin() {
-
- EJBQLJoinAppender joinAppender = context.getTranslator().getJoinAppender(context);
-
- String newPath = idPath + '.' + lastPathComponent;
- String oldPath = joinAppender.registerReusableJoin(idPath, lastPathComponent, newPath);
-
- this.fullPath = fullPath + '.' + lastPathComponent;
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- if (oldPath != null) {
- this.idPath = oldPath;
- ObjRelationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
- if (lastRelationship != null) {
- DbEntity targetDbEntity = lastRelationship.getTargetEntity().getDbEntity();
-
- this.lastAlias = context.getTableAlias(fullPath,
- quotes.quotedFQN(targetDbEntity.getCatalog(), targetDbEntity.getSchema(),
- targetDbEntity.getName()));
- } else {
- DbEntity currentDbEntity = currentEntity.getDbEntity();
- String tableName = quotes.quotedFQN(currentDbEntity.getCatalog(), currentDbEntity.getSchema(),
- currentDbEntity.getName());
- this.lastAlias = context.getTableAlias(oldPath, tableName);
- }
- } else {
- ObjRelationship lastRelationship = currentEntity.getRelationship(lastPathComponent);
-
- ObjEntity targetEntity;
- if (lastRelationship != null) {
- targetEntity = lastRelationship.getTargetEntity();
- } else {
- targetEntity = currentEntity;
- }
-
- // register join
- if (innerJoin) {
- joinAppender.appendInnerJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
- } else {
- joinAppender.appendOuterJoin(joinMarker, new EJBQLTableId(idPath), new EJBQLTableId(fullPath));
-
- }
-
- DbEntity targetDbEntity = targetEntity.getDbEntity();
- this.lastAlias = context.getTableAlias(fullPath,
- quotes.quotedFQN(targetDbEntity.getCatalog(), targetDbEntity.getSchema(),
- targetDbEntity.getName()));
-
- this.idPath = newPath;
- }
- }
-
- protected void processIntermediatePathComponent() {
- ObjRelationship relationship = currentEntity.getRelationship(lastPathComponent);
- if (relationship == null) {
- throw new EJBQLException("Unknown relationship '" + lastPathComponent + "' for entity '"
- + currentEntity.getName() + "'");
- }
-
- this.currentEntity = relationship.getTargetEntity();
- }
-
- protected void processLastPathComponent() {
-
- ObjAttribute attribute = currentEntity.getAttribute(lastPathComponent);
-
- if (attribute != null) {
- processTerminatingAttribute(attribute);
- return;
- }
-
- ObjRelationship relationship = currentEntity.getRelationship(lastPathComponent);
- if (relationship != null) {
- processTerminatingRelationship(relationship);
- return;
- }
-
- throw new IllegalStateException("Invalid path component: " + lastPathComponent);
- }
-
- protected void processTerminatingAttribute(ObjAttribute attribute) {
-
- DbEntity table = null;
- Iterator<?> it = attribute.getDbPathIterator();
- while (it.hasNext()) {
- Object pathComponent = it.next();
- if (pathComponent instanceof DbAttribute dbAttribute) {
- table = dbAttribute.getEntity();
- }
- }
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- if (isUsingAliases()) {
- String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
- context.append(' ').append(alias).append('.')
- .append(quotes.quoted(attribute.getDbAttribute().getName()));
- } else {
- context.append(' ').append(quotes.quoted(attribute.getDbAttribute().getName()));
- }
- }
-
- protected void processTerminatingRelationship(ObjRelationship relationship) {
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- if (relationship.isSourceIndependentFromTargetChange()) {
-
- // (andrus) use an outer join for to-many matches.. This is somewhat
- // different
- // from traditional Cayenne SelectQuery, as EJBQL spec does not
- // allow regular
- // path matches done against to-many relationships, and instead
- // provides
- // MEMBER OF and IS EMPTY operators. Outer join is needed for IS
- // EMPTY... I
- // guess MEMBER OF could've been done with an inner join though..
- this.innerJoin = false;
- resolveJoin();
-
- DbRelationship dbRelationship = chooseDbRelationship(relationship);
- DbEntity table = dbRelationship.getTargetEntity();
-
- String alias = this.lastAlias != null
- ? lastAlias
- : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- Collection<DbAttribute> pks = table.getPrimaryKeys();
-
- if (pks.size() == 1) {
- DbAttribute pk = pks.iterator().next();
- context.append(' ');
- if (isUsingAliases()) {
- context.append(alias).append('.');
- }
- context.append(quotes.quoted(pk.getName()));
- } else {
- throw new EJBQLException("Multi-column PK to-many matches are not yet supported.");
- }
-
- } else {
- // match FK against the target object
-
- DbRelationship dbRelationship = chooseDbRelationship(relationship);
- DbEntity table = dbRelationship.getSourceEntity();
-
- String alias = this.lastAlias != null
- ? lastAlias
- : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- List<DbJoin> joins = dbRelationship.getJoins();
-
- if (joins.size() == 1) {
- DbJoin join = joins.get(0);
- context.append(' ');
- if (isUsingAliases()) {
- context.append(alias).append('.');
- }
- context.append(quotes.quoted(join.getSource().getName()));
- } else {
- Map<String, String> multiColumnMatch = new HashMap<>(joins.size() + 2);
-
- for (DbJoin join : joins) {
- String column = isUsingAliases() ? alias + "." + join.getSourceName() : join.getSourceName();
-
- multiColumnMatch.put(join.getTargetName(), column);
- }
-
- appendMultiColumnPath(EJBQLMultiColumnOperand.getPathOperand(context, multiColumnMatch));
- }
- }
- }
-
- /**
- * Checks if the object relationship is flattened and then chooses the
- * corresponding db relationship. The last in idPath if isFlattened and the
- * first in list otherwise.
- *
- * @param relationship
- * the object relationship
- *
- * @return {@link DbRelationship}
- */
- protected DbRelationship chooseDbRelationship(ObjRelationship relationship) {
-
- List<DbRelationship> dbRelationships = relationship.getDbRelationships();
- CayennePath dbRelationshipPath = relationship.getDbRelationshipPath();
-
- if (dbRelationshipPath.length() > 1) {
- String dbRelName = dbRelationshipPath.last().value();
- for (DbRelationship dbR : dbRelationships) {
- if (dbR.getName().equals(dbRelName)) {
- return dbR;
- }
- }
- }
- return relationship.getDbRelationships().get(0);
-
- }
-
- public boolean isUsingAliases() {
- return usingAliases;
- }
-
- public void setUsingAliases(boolean usingAliases) {
- this.usingAliases = usingAliases;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectColumnsTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectColumnsTranslator.java
deleted file mode 100644
index f1decf7ad..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectColumnsTranslator.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.dba.TypesMapping;
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjRelationship;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Translator of the EJBQL select clause.
- *
- * @since 3.0
- */
-public class EJBQLSelectColumnsTranslator extends EJBQLBaseVisitor {
-
- protected EJBQLTranslationContext context;
- private int expressionsCount;
-
- protected EJBQLSelectColumnsTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- @Override
- public boolean visitSelectExpression(EJBQLExpression expression) {
- if (expressionsCount++ > 0) {
- context.append(",");
- }
-
- return true;
- }
-
- @Override
- public boolean visitAggregate(EJBQLExpression expression) {
- expression.visit(context.getTranslator().getAggregateColumnTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitDbPath(EJBQLExpression expression, int finishedChildIndex) {
-
- EJBQLDbPathTranslator pathTranslator = new EJBQLDbPathTranslator(context) {
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- throw new EJBQLException("Can't use multi-column paths in column clause");
- }
-
- @Override
- protected void processTerminatingRelationship(DbRelationship relationship) {
- Map<String, String> xfields = null;
- if (context.isAppendingResultColumns()) {
- xfields = context.nextEntityResult().fields();
- }
-
- final Map<String, String> fields = xfields;
-
- DbEntity table = relationship.getTargetEntity();
- Collection<DbAttribute> dbAttr = table.getAttributes();
-
- if (dbAttr.size() > 0) {
- resolveJoin();
- }
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = this.lastAlias != null
- ? lastAlias
- : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- boolean first = true;
- for (DbAttribute dbAttribute : dbAttr) {
- context.append(!first ? ", " : " ");
- appendColumn(TypesMapping.getJavaBySqlType(dbAttribute), alias, dbAttribute,
- fields != null ? fields.get(dbAttribute.getName()) : "");
- first = false;
- }
- }
-
- @Override
- protected void processTerminatingAttribute(DbAttribute attribute) {
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = this.lastAlias != null
- ? lastAlias
- : context.getTableAlias(idPath,
- quotes.quotedFQN(currentEntity.getCatalog(), currentEntity.getSchema(),
- currentEntity.getName()));
-
- appendColumn(TypesMapping.getJavaBySqlType(attribute), alias, attribute,
- context.isAppendingResultColumns() ? context.nextColumnAlias() : "");
- }
- };
-
- expression.visit(pathTranslator);
- return false;
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- EJBQLPathTranslator pathTranslator = new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- throw new EJBQLException("Can't use multi-column paths in column clause");
- }
-
- @Override
- protected void processTerminatingRelationship(ObjRelationship relationship) {
-
- Map<String, String> xfields = null;
- if (context.isAppendingResultColumns()) {
- xfields = context.nextEntityResult().fields();
- }
-
- final Map<String, String> fields = xfields;
-
- Collection<DbAttribute> dbAttr = relationship.getTargetEntity().getDbEntity().getAttributes();
-
- DbRelationship dbRelationship = relationship.getDbRelationships().get(0);
- DbEntity table = dbRelationship.getTargetEntity();
-
- Iterator<DbAttribute> it = dbAttr.iterator();
- if (dbAttr.size() > 0) {
- resolveJoin();
- }
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = this.lastAlias != null
- ? lastAlias
- : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
-
- boolean first = true;
- while (it.hasNext()) {
-
- context.append(!first ? ", " : " ");
-
- DbAttribute dbAttribute = it.next();
- appendColumn(TypesMapping.getJavaBySqlType(dbAttribute), alias, dbAttribute,
- fields != null ? fields.get(dbAttribute.getName()) : "");
-
- first = false;
- }
-
- }
-
- @Override
- protected void processTerminatingAttribute(ObjAttribute attribute) {
- DbEntity table = currentEntity.getDbEntity();
- QuotingStrategy quotes = context.getIdentifierQuotes();
- String alias = this.lastAlias != null
- ? lastAlias
- : context.getTableAlias(idPath,
- quotes.quotedFQN(table.getCatalog(), table.getSchema(), table.getName()));
- if (attribute.isFlattened()) {
- Iterator<?> dbPathIterator = attribute.getDbPathIterator();
- EJBQLTableId lhsId = new EJBQLTableId(idPath);
-
- while (dbPathIterator.hasNext()) {
- Object pathPart = dbPathIterator.next();
- // DbRelationships not processed, because they will be processed later when appending table
- if (pathPart == null) {
- throw new CayenneRuntimeException("ObjAttribute has no component: %s", attribute.getName());
- } else if (pathPart instanceof DbAttribute dbAttribute) {
- DbEntity attributeEntity = dbAttribute.getEntity();
- appendColumn(attribute.getType(),
- context.getTableAlias(lhsId.getEntityId(),
- quotes.quotedFQN(attributeEntity.getCatalog(), attributeEntity.getSchema(),
- attributeEntity.getName())),
- dbAttribute, context.isAppendingResultColumns() ? context.nextColumnAlias() : "");
-
- }
-
- }
-
- } else {
-
- DbAttribute dbAttribute = attribute.getDbAttribute();
-
- appendColumn(attribute.getType(), alias, dbAttribute,
- context.isAppendingResultColumns() ? context.nextColumnAlias() : "");
- }
- }
-
- };
- expression.visit(pathTranslator);
- return false;
- }
-
- @Override
- public boolean visitIdentifier(EJBQLExpression expression) {
- expression.visit(context.getTranslator().getIdentifierColumnsTranslator(context));
- return false;
- }
-
- public void appendColumn(String javaType, String alias, DbAttribute dbAttribute, String columnAlias) {
- if (context.isAppendingResultColumns()) {
- context.append(" #result('");
- } else {
- context.append(' ');
- }
-
- QuotingStrategy quotes = context.getIdentifierQuotes();
- context.append(alias).append('.').append(quotes.quoted(dbAttribute.getName()));
-
- if (context.isAppendingResultColumns()) {
- // String columnAlias = context.nextColumnAlias();
-
- // TODO: andrus 6/27/2007 - the last parameter is an unofficial
- // "jdbcType" pending CAY-813 implementation, switch to #column directive
- context.append("' '").append(javaType).append("' '").append(columnAlias).append("' '").append(columnAlias)
- .append("' " + dbAttribute.getType()).append(")");
- }
-
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslator.java
deleted file mode 100644
index d267569d8..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLSelectTranslator.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-/**
- * A translator of EJBQL SELECT statements into SQL.
- *
- * @since 3.0
- */
-public class EJBQLSelectTranslator extends EJBQLBaseVisitor {
-
- protected EJBQLTranslationContext context;
-
- protected EJBQLSelectTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- @Override
- public boolean visitDistinct(EJBQLExpression expression) {
- // "distinct" is appended via a marker as sometimes a later match on to-many would
- // require a DISTINCT insertion.
- context.pushMarker(context.makeDistinctMarker(), true);
- context.append(" DISTINCT");
- context.popMarker();
- return true;
- }
-
- @Override
- public boolean visitFrom(EJBQLExpression expression, int finishedChildIndex) {
- context.append(" FROM");
- context.setAppendingResultColumns(false);
- expression.visit(context.getTranslator().getFromTranslator(context));
- context.markCurrentPosition(context.makeWhereMarker());
- context.markCurrentPosition(context.makeEntityQualifierMarker());
- return false;
- }
-
- @Override
- public boolean visitGroupBy(EJBQLExpression expression) {
- context.append(" GROUP BY");
- expression.visit(context.getTranslator().getGroupByTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitHaving(EJBQLExpression expression) {
- context.append(" HAVING");
- expression.visit(context.getTranslator().getConditionTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitOrderBy(EJBQLExpression expression) {
- context.append(" ORDER BY");
- expression.visit(context.getTranslator().getOrderByTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitSelect(EJBQLExpression expression) {
- // this ensures that result columns are appeneded only in top-level select, but
- // not subselect (as 'visitSelect' is not called on subselect)
- context.setAppendingResultColumns(true);
- return true;
- }
-
- @Override
- public boolean visitSelectClause(EJBQLExpression expression) {
- context.append("SELECT");
- context.markCurrentPosition(context.makeDistinctMarker());
- return true;
- }
-
- @Override
- public boolean visitSelectExpressions(EJBQLExpression expression) {
- expression.visit(context.getTranslator().getSelectColumnsTranslator(
- context));
- return false;
- }
-
- @Override
- public boolean visitWhere(EJBQLExpression expression) {
- // "WHERE" is appended via a marker as it may have been already appended when an
- // entity inheritance qualifier was applied.
- context.pushMarker(context.makeWhereMarker(), true);
- context.append(" WHERE");
- context.popMarker();
-
- if (!context.findOrCreateMarkedBuffer(context.makeEntityQualifierMarker()).isEmpty()) {
- context.append(" AND");
- }
-
- expression.visit(context.getTranslator().getConditionTranslator(context));
- return false;
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTableId.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTableId.java
deleted file mode 100644
index 4f7009025..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTableId.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Iterator;
-import java.util.Objects;
-
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-/**
- * A helper class representing an "id" of a database table during EJBQL translation. EJBQL
- * "ids" point to ObjEntities, but during translation we need id's that represent both
- * "root" tables that map back to an ObjEntity, as well as joined tables for flattened
- * attributes and relationships. EJBQLTableId is intended to represent both types of
- * tables.
- *
- * @since 3.0
- */
-class EJBQLTableId {
-
- private static String appendPath(EJBQLTableId baseId, String dbPathSuffix) {
- if (baseId.getDbPath() == null) {
- return dbPathSuffix;
- }
-
- if (dbPathSuffix == null) {
- return baseId.getDbPath();
- }
-
- return baseId.getDbPath() + "." + dbPathSuffix;
- }
-
- private String entityId;
- private String dbPath;
-
- EJBQLTableId(String entityId) {
- this(entityId, null);
- }
-
- EJBQLTableId(EJBQLTableId baseId, String dbPathSuffix) {
- this(baseId.getEntityId(), appendPath(baseId, dbPathSuffix));
- }
-
- EJBQLTableId(String entityId, String dbPath) {
-
- if (entityId == null) {
- throw new NullPointerException("Null entityId");
- }
-
- this.entityId = entityId;
- this.dbPath = dbPath;
- }
-
- boolean isPrimaryTable() {
- return dbPath == null;
- }
-
- /**
- * Returns a DbEntity corresponding to the ID, that could be a root entity for the id,
- * or a joined entity.
- */
- DbEntity getDbEntity(EJBQLTranslationContext context) {
- ClassDescriptor descriptor = context.getEntityDescriptor(entityId);
- DbEntity rootEntity = descriptor.getEntity().getDbEntity();
-
- if (dbPath == null) {
- return rootEntity;
- }
-
- DbRelationship r = null;
- Iterator<?> it = rootEntity.resolvePathComponents(dbPath);
- while (it.hasNext()) {
- r = (DbRelationship) it.next();
- }
-
- return (DbEntity) r.getTargetEntity();
- }
-
- String getEntityId() {
- return entityId;
- }
-
- String getDbPath() {
- return dbPath;
- }
-
- @Override
- public int hashCode() {
- int hash = entityId.hashCode();
-
- if (dbPath != null) {
- hash += dbPath.hashCode() * 7;
- }
-
- return hash;
- }
-
- @Override
- public boolean equals(Object object) {
-
- if (this == object) {
- return true;
- }
-
- if (!(object instanceof EJBQLTableId)) {
- return false;
- }
-
- EJBQLTableId id = (EJBQLTableId) object;
-
- if (!Objects.equals(entityId, id.entityId)) {
- return false;
- }
-
- if (!Objects.equals(dbPath, id.dbPath)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public String toString() {
- return dbPath != null ? entityId + "/" + dbPath : entityId;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTranslationContext.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTranslationContext.java
deleted file mode 100644
index 07a71dc31..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLTranslationContext.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.query.EJBQLQuery;
-import org.apache.cayenne.query.EntityResultSegment;
-import org.apache.cayenne.query.QueryMetadata;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.query.ResultSegment;
-import org.apache.cayenne.query.ScalarResultSegment;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A context used for translating of EJBQL to SQL.
- *
- * @since 3.0
- */
-public class EJBQLTranslationContext {
-
- private EJBQLCompiledExpression compiledExpression;
- protected Map<String, Object> namedParameters;
- protected Map<Integer, Object> positionalParameters;
- private EJBQLTranslator translator;
- private DbAdapter adapter;
- private QuotingStrategy quotingStrategy;
- private EntityResolver entityResolver;
- private List<ResultSegment> resultSetMetadata;
-
- private Map<String, String> tableAliases;
- private Map<String, Object> boundParameters;
- private Map<String, Object> attributes;
- private Map<String, String> idAliases;
- private int resultDescriptorPosition;
- private boolean usingAliases;
- private boolean caseInsensitive;
- private List<StringBuilder> bufferStack;
- private List<StringBuilder> bufferChain;
- private StringBuilder stackTop;
- private int subselectCount;
- private QueryMetadata queryMetadata;
-
- // a flag indicating whether column expressions should be treated as result columns or
- // not.
- private boolean appendingResultColumns;
-
- public EJBQLTranslationContext(
- EntityResolver entityResolver,
- EJBQLQuery<?> query,
- EJBQLCompiledExpression compiledExpression,
- EJBQLTranslator translator,
- DbAdapter adapter,
- QuotingStrategy quotingStrategy) {
-
- this.entityResolver = entityResolver;
- this.compiledExpression = compiledExpression;
- this.resultSetMetadata = query.getMetaData(entityResolver).getResultSetMapping();
-
- this.namedParameters = query.getNamedParameters();
- this.positionalParameters = query.getPositionalParameters();
- this.translator = translator;
- this.adapter = adapter;
- this.usingAliases = true;
- this.caseInsensitive = false;
- this.queryMetadata = query.getMetaData(entityResolver);
- this.quotingStrategy = quotingStrategy;
-
- // buffer stack will hold named buffers during translation in the order they were
- // requested
- this.bufferStack = new ArrayList<>();
-
- // buffer chain will hold named and unnamed buffers in the order they should be
- // concatenated
- this.bufferChain = new ArrayList<>();
-
- stackTop = new StringBuilder();
- bufferChain.add(stackTop);
- bufferStack.add(stackTop);
- }
-
- public SQLTemplate<?> getQuery() {
-
- // concatenate buffers...
- StringBuilder main = bufferChain.get(0);
- for (int i = 1; i < bufferChain.size(); i++) {
- main.append(bufferChain.get(i));
- }
-
- String sql = main.length() > 0 ? main.toString() : null;
- SQLTemplate<?> query = new SQLTemplate<>(compiledExpression
- .getRootDescriptor()
- .getObjectClass(), sql);
- query.setParams(boundParameters);
- return query;
- }
-
- public QueryMetadata getMetadata() {
- return queryMetadata;
- }
-
- private String resolveId(String id) {
- if (idAliases == null) {
- return id;
- }
-
- String resolvedAlias = idAliases.get(id);
- if (resolvedAlias != null) {
- return resolvedAlias;
- }
-
- return id;
- }
-
- EJBQLTranslator getTranslator() {
- return translator;
- }
-
- /**
- * @since 5.0
- */
- DbAdapter getAdapter() {
- return adapter;
- }
-
- EntityResolver getEntityResolver() {
- return entityResolver;
- }
-
- /**
- * Looks up entity descriptor for an identifier that can be a compiled expression id
- * or one of the aliases.
- */
- public ClassDescriptor getEntityDescriptor(String id) {
- return compiledExpression.getEntityDescriptor(resolveId(id));
- }
-
- List<DbRelationship> getIncomingRelationships(EJBQLTableId id) {
-
- List<DbRelationship> incoming = compiledExpression
- .getIncomingRelationships(resolveId(id.getEntityId()));
-
- // append tail of flattened relationships...
- if (id.getDbPath() != null) {
-
- DbEntity entity;
-
- if (incoming == null || incoming.isEmpty()) {
- entity = compiledExpression
- .getEntityDescriptor(id.getEntityId())
- .getEntity()
- .getDbEntity();
- } else {
- DbRelationship last = incoming.get(incoming.size() - 1);
- entity = last.getTargetEntity();
- }
-
- incoming = new ArrayList<>(incoming);
-
- Iterator<?> it = entity.resolvePathComponents(id.getDbPath());
- while (it.hasNext()) {
- incoming.add((DbRelationship) it.next());
- }
- }
-
- return incoming;
- }
-
- /**
- * Creates a previously unused id alias for an entity identified by an id.
- */
- String createIdAlias(String id) {
-
- if (idAliases == null) {
- idAliases = new HashMap<>();
- }
-
- for (int i = 0; i < 1000; i++) {
- String alias = id + "_alias" + i;
- if (idAliases.containsKey(alias)) {
- continue;
- }
-
- if (compiledExpression.getEntityDescriptor(alias) != null) {
- continue;
- }
-
- idAliases.put(alias, id);
- return alias;
- }
-
- throw new EJBQLException("Failed to create id alias");
- }
-
- /**
- * Inserts a marker in the SQL, mapped to a StringBuilder that can be later filled
- * with content.
- */
- void markCurrentPosition(String marker) {
-
- StringBuilder buffer = findOrCreateMarkedBuffer(marker);
- bufferChain.add(buffer);
-
- // immediately create unmarked buffer after the marked one and replace the bottom
- // of the stack with it
- StringBuilder tailBuffer = new StringBuilder();
- bufferChain.add(tailBuffer);
- bufferStack.set(0, tailBuffer);
- stackTop = bufferStack.get(bufferStack.size() - 1);
- }
-
- /**
- * Switches the current buffer to a marked buffer, pushing the currently used buffer
- * on the stack. Note that this can be done even before the marker is inserted in the
- * main buffer. If "reset" is true, any previous contents of the marker are cleared.
- */
- public void pushMarker(String marker, boolean reset) {
-
- stackTop = findOrCreateMarkedBuffer(marker);
- if (reset) {
- stackTop.delete(0, stackTop.length());
- }
-
- bufferStack.add(stackTop);
- }
-
- /**
- * Pops a marker stack, switching to the previously used marker.
- */
- void popMarker() {
- int lastIndex = bufferStack.size() - 1;
- bufferStack.remove(lastIndex);
- stackTop = bufferStack.get(lastIndex - 1);
- }
-
- StringBuilder findOrCreateMarkedBuffer(String marker) {
- StringBuilder buffer = (StringBuilder) getAttribute(marker);
- if (buffer == null) {
- buffer = new StringBuilder();
-
- // register mapping of internal to external marker
- setAttribute(marker, buffer);
- }
-
- return buffer;
- }
-
- /**
- * Returns a context "attribute" stored for the given name. Attributes is a state
- * preservation mechanism used by translators and have the same scope as the context.
- */
- Object getAttribute(String name) {
- return attributes != null ? attributes.get(name) : null;
- }
-
- /**
- * Sets a context "attribute". Attributes is a state preservation mechanism used by
- * translators and have the same scope as the context.
- */
- void setAttribute(String var, Object value) {
- if (attributes == null) {
- attributes = new HashMap<>();
- }
-
- attributes.put(var, value);
- }
-
- /**
- * Appends a piece of SQL to the internal buffer.
- */
- public EJBQLTranslationContext append(String chunk) {
- stackTop.append(chunk);
- return this;
- }
-
- /**
- * Appends a piece of SQL to the internal buffer.
- */
- public EJBQLTranslationContext append(char chunk) {
- stackTop.append(chunk);
- return this;
- }
-
- /**
- * Deletes a specified number of characters from the end of the current buffer.
- */
- EJBQLTranslationContext trim(int n) {
- int len = stackTop.length();
-
- if (len >= n) {
- stackTop.delete(len - n, len);
- }
- return this;
- }
-
- EJBQLCompiledExpression getCompiledExpression() {
- return compiledExpression;
- }
-
- String bindPositionalParameter(int position) {
- return bindParameter(positionalParameters.get(position));
- }
-
- /**
- * <p>This is used in the processing of parameters into lists for the IN clause and
- * is able to return a list of values that can be used to represent the bound
- * parameter.</p>
- */
-
- List<String> bindPositionalParameterFlatteningCollection(int position) {
- return bindParameters(positionalParameters.get(position));
- }
-
- String bindNamedParameter(String name) {
- return bindParameter(namedParameters.get(name));
- }
-
- /**
- * <p>This is used in the processing of parameters into lists for the IN clause and
- * is able to return a list of values that can be used to represent the bound
- * parameter.</p>
- */
-
- List<String> bindNamedParameterFlatteningCollection(String name) {
- return bindParameters(namedParameters.get(name));
- }
-
- /**
- * <p>This method takes a value object which may be a collection or a non-collection. If it
- * is a collection then it will bind all of the values in the collection. If it is a non-
- * collection then it will bind that single object.</p>
- *
- * @param value
- * @return
- */
-
- List<String> bindParameters(Object value) {
- if (Collection.class.isAssignableFrom(value.getClass())) {
- Iterator<?> parameterValueIterator = ((Collection<?>) value).iterator();
- List<String> result = new ArrayList<>();
-
- while (parameterValueIterator.hasNext()) {
- result.add(bindParameter(parameterValueIterator.next()));
- }
-
- return result;
- }
-
- return Collections.singletonList(bindParameter(value));
- }
-
- /**
- * Creates a new parameter variable, binding provided value to it.
- */
- String bindParameter(Object value) {
- return bindParameter(value, "id");
- }
-
- void rebindParameter(String boundName, Object newValue) {
- boundParameters.put(boundName, newValue);
- }
-
- /**
- * Creates a new parameter variable with the specified prefix, binding provided value
- * to it.
- */
- String bindParameter(Object value, String prefix) {
- if (boundParameters == null) {
- boundParameters = new HashMap<>();
- }
-
- String var = prefix + boundParameters.size();
- boundParameters.put(var, value);
- return var;
- }
-
- Object getBoundParameter(String name) {
- return boundParameters != null ? boundParameters.get(name) : null;
- }
-
- /**
- * Retrieves a SQL alias for the combination of EJBQL id variable and a table name. If
- * such alias hasn't been used, it is created on the fly.
- */
- protected String getTableAlias(String idPath, String tableName) {
-
- if (!isUsingAliases()) {
- return tableName;
- }
-
- StringBuilder keyBuffer = new StringBuilder();
-
- // per JPA spec, 4.4.2, "Identification variables are case insensitive.", while
- // relationship path is case-sensitive
-
- int dot = idPath.indexOf('.');
- if (dot > 0) {
- keyBuffer.append(idPath.substring(0, dot).toLowerCase()).append(
- idPath.substring(dot));
- } else {
- keyBuffer.append(idPath.toLowerCase());
- }
-
- String key = keyBuffer.append(':').append(tableName).toString();
-
- String alias;
-
- if (tableAliases != null) {
- alias = tableAliases.get(key);
- } else {
- tableAliases = new HashMap<>();
- alias = null;
- }
-
- if (alias == null) {
- alias = "t" + tableAliases.size();
- tableAliases.put(key, alias);
- }
-
- return alias;
- }
-
- /**
- * Returns a positional EntityResult, incrementing position index on each call.
- */
- EntityResultSegment nextEntityResult() {
-
- if (resultSetMetadata == null) {
- throw new EJBQLException(
- "No result set mapping exists for expression, can't map EntityResult");
- }
-
- return (EntityResultSegment) resultSetMetadata.get(resultDescriptorPosition++);
- }
-
- /**
- * Returns a positional column alias, incrementing position index on each call.
- */
- String nextColumnAlias() {
-
- if (resultSetMetadata == null) {
- throw new EJBQLException(
- "No result set mapping exists for expression, can't map column aliases");
- }
-
- return ((ScalarResultSegment) resultSetMetadata.get(resultDescriptorPosition++))
- .column();
- }
-
- public boolean isAppendingResultColumns() {
- return appendingResultColumns;
- }
-
- void setAppendingResultColumns(boolean appendingResultColumns) {
- this.appendingResultColumns = appendingResultColumns;
- }
-
- public boolean isUsingAliases() {
- return usingAliases;
- }
-
- public void setUsingAliases(boolean useAliases) {
- this.usingAliases = useAliases;
- }
-
- public boolean isCaseInsensitive() {
- return caseInsensitive;
- }
-
- public void setCaseInsensitive(boolean caseInsensitive) {
- this.caseInsensitive = caseInsensitive;
- }
-
- /**
- * @since 5.0
- */
- public QuotingStrategy getIdentifierQuotes() {
- return quotingStrategy;
- }
-
- public void onSubselect() {
- subselectCount++;
- }
-
- public String makeDistinctMarker() {
- return "DISTINCT_MARKER" + subselectCount;
- }
-
- String makeWhereMarker() {
- return "WHERE_MARKER" + subselectCount;
- }
-
- String makeEntityQualifierMarker() {
- return "ENTITY_QUALIIER" + subselectCount;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateItemTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateItemTranslator.java
deleted file mode 100644
index 362c274da..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateItemTranslator.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import java.util.Iterator;
-
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-/**
- * @since 3.0
- */
-class EJBQLUpdateItemTranslator extends EJBQLConditionTranslator {
-
- EJBQLUpdateItemTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
- // unexpected, but make sure super is not called....
- return false;
- }
-
- @Override
- public boolean visitUpdateItem(EJBQLExpression expression, int finishedChildIndex) {
-
- if (finishedChildIndex == expression.getChildrenCount() - 1) {
-
- // check multicolumn match condition and undo op insertion and append it
- // from scratch if needed
- if (multiColumnOperands != null) {
-
- if (multiColumnOperands.size() != 2) {
- throw new EJBQLException(
- "Invalid multi-column equals expression. Expected 2 multi-column operands, got "
- + multiColumnOperands.size());
- }
-
- context.trim(2);
-
- EJBQLMultiColumnOperand lhs = multiColumnOperands.get(0);
- EJBQLMultiColumnOperand rhs = multiColumnOperands.get(1);
-
- Iterator<?> it = lhs.getKeys().iterator();
- while (it.hasNext()) {
- Object key = it.next();
-
- lhs.appendValue(key);
- context.append(" =");
- rhs.appendValue(key);
-
- if (it.hasNext()) {
- context.append(',');
- }
- }
-
- multiColumnOperands = null;
- }
- }
-
- return true;
- }
-
- @Override
- public boolean visitUpdateField(EJBQLExpression expression, int finishedChildIndex) {
-
- EJBQLPathTranslator pathTranslator = new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- EJBQLUpdateItemTranslator.this.addMultiColumnOperand(operand);
- }
-
- @Override
- public boolean visitUpdateField(
- EJBQLExpression expression,
- int finishedChildIndex) {
- return visitPath(expression, finishedChildIndex);
- }
- };
-
- // some DB's do not support aliases in SET (Postgresql)
- pathTranslator.setUsingAliases(false);
-
- expression.visit(pathTranslator);
- return false;
- }
-
- @Override
- public boolean visitEquals(EJBQLExpression expression, int finishedChildIndex) {
- // unlike super, Equals here has no children and is itself a child of UpdateItem
- context.append(" =");
- return false;
- }
-
- @Override
- public boolean visitUpdateValue(EJBQLExpression expression) {
-
- // a criteria for NULL is UpdateValue with no children
- if (expression.getChildrenCount() == 0) {
- context.append(" NULL");
- return false;
- }
-
- return true;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateTranslator.java
deleted file mode 100644
index 65ce8a66b..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/EJBQLUpdateTranslator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-/**
- * A translator of EJBQL UPDATE statements into SQL.
- *
- * @since 3.0
- */
-class EJBQLUpdateTranslator extends EJBQLBaseVisitor {
-
- private EJBQLTranslationContext context;
- private int itemCount;
-
- EJBQLUpdateTranslator(EJBQLTranslationContext context) {
- this.context = context;
- }
-
- EJBQLTranslationContext getContext() {
- return context;
- }
-
- @Override
- public boolean visitUpdate(EJBQLExpression expression) {
- context.append("UPDATE");
- return true;
- }
-
- @Override
- public boolean visitWhere(EJBQLExpression expression) {
- context.append(" WHERE");
- expression.visit(context.getTranslator().getConditionTranslator(context));
- return false;
- }
-
- @Override
- public boolean visitFrom(EJBQLExpression expression, int finishedChildIndex) {
- expression.visit(context.getTranslator().getFromTranslator(context));
-
- return false;
- }
-
- @Override
- public boolean visitUpdateItem(EJBQLExpression expression, int finishedChildIndex) {
- if (itemCount++ > 0) {
- context.append(',');
- }
- else {
- context.append(" SET");
- }
-
- expression.visit(context.getTranslator().getUpdateItemTranslator(context));
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/JdbcEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/JdbcEJBQLTranslator.java
deleted file mode 100644
index fa8544511..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/access/translator/ejbql/JdbcEJBQLTranslator.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.access.translator.ejbql;
-
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * A default {@link EJBQLTranslator}.
- *
- * @since 3.0
- */
-public class JdbcEJBQLTranslator implements EJBQLTranslator {
-
- protected static final String JOIN_APPENDER_KEY = "$JoinAppender";
-
- protected boolean caseInsensitive = false;
-
- public EJBQLJoinAppender getJoinAppender(EJBQLTranslationContext context) {
- EJBQLJoinAppender appender = (EJBQLJoinAppender) context
- .getAttribute(JOIN_APPENDER_KEY);
-
- if (appender == null) {
- appender = new EJBQLJoinAppender(context);
- context.setAttribute(JOIN_APPENDER_KEY, appender);
- }
-
- return appender;
- }
-
- public EJBQLExpressionVisitor getDeleteTranslator(EJBQLTranslationContext context) {
- context.setUsingAliases(false);
- return new EJBQLDeleteTranslator(context);
- }
-
- public EJBQLExpressionVisitor getSelectTranslator(EJBQLTranslationContext context) {
- return new EJBQLSelectTranslator(context);
- }
-
- public EJBQLExpressionVisitor getUpdateTranslator(EJBQLTranslationContext context) {
- context.setUsingAliases(false);
- return new EJBQLUpdateTranslator(context);
- }
-
- public EJBQLExpressionVisitor getAggregateColumnTranslator(
- EJBQLTranslationContext context) {
- return new EJBQLAggregateColumnTranslator(context);
- }
-
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- context.setCaseInsensitive(caseInsensitive);
- return new EJBQLConditionTranslator(context);
- }
-
- public EJBQLExpressionVisitor getFromTranslator(EJBQLTranslationContext context) {
- return new EJBQLFromTranslator(context);
- }
-
- public EJBQLExpressionVisitor getGroupByTranslator(EJBQLTranslationContext context) {
- return new EJBQLGroupByTranslator(context);
- }
-
- public EJBQLExpressionVisitor getIdentifierColumnsTranslator(
- EJBQLTranslationContext context) {
- if(context.getMetadata().getPageSize() > 0){
- return new EJBQLIdColumnsTranslator(context);
- }
- else{
- return new EJBQLIdentifierColumnsTranslator(context);
- }
- }
-
- public EJBQLExpressionVisitor getOrderByTranslator(EJBQLTranslationContext context) {
- return new EJBQLOrderByTranslator(context);
- }
-
- public EJBQLExpressionVisitor getSelectColumnsTranslator(
- EJBQLTranslationContext context) {
- return new EJBQLSelectColumnsTranslator(context);
- }
-
- public EJBQLExpressionVisitor getUpdateItemTranslator(EJBQLTranslationContext context) {
- return new EJBQLUpdateItemTranslator(context);
- }
-
- public void setCaseInsensitive(boolean caseInsensitive) {
- this.caseInsensitive = caseInsensitive;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java
index 3fe97ec41..b7fcf3225 100644
--- a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java
+++ b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java
@@ -34,14 +34,12 @@ import org.apache.cayenne.access.flush.operation.HardDeleteDbRowOpFactory;
import org.apache.cayenne.access.jdbc.reader.DefaultRowReaderFactory;
import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
import org.apache.cayenne.access.translator.BatchTranslator;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.translator.SQLTemplateTranslator;
import org.apache.cayenne.access.translator.SelectTranslator;
import org.apache.cayenne.access.translator.batch.DeleteBatchTranslator;
import org.apache.cayenne.access.translator.batch.InsertBatchTranslator;
import org.apache.cayenne.access.translator.batch.UpdateBatchTranslator;
-import org.apache.cayenne.access.translator.ejbql.DbAdapterDelegatedEJBQLTranslator;
import org.apache.cayenne.access.translator.procedure.DbAdapterDelegatedProcedureTranslator;
import org.apache.cayenne.access.translator.select.DbAdapterDelegatedSelectTranslator;
import org.apache.cayenne.access.translator.sqltemplate.DefaultSQLTemplateTranslator;
@@ -408,7 +406,6 @@ public class CoreModule implements Module {
binder.bind(Key.get(BatchTranslator.class, BatchTranslator.DELETE)).to(DeleteBatchTranslator.class);
binder.bind(SelectTranslator.class).to(DbAdapterDelegatedSelectTranslator.class);
binder.bind(ProcedureTranslator.class).to(DbAdapterDelegatedProcedureTranslator.class);
- binder.bind(EJBQLTranslator.class).to(DbAdapterDelegatedEJBQLTranslator.class);
// a default ObjectMapRetainStrategy used to create objects map for
// ObjectStore
diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DefaultDataNodeFactory.java b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DefaultDataNodeFactory.java
index c38fdaab9..b25f698fd 100644
--- a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DefaultDataNodeFactory.java
+++ b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DefaultDataNodeFactory.java
@@ -23,7 +23,6 @@ import org.apache.cayenne.access.dbsync.SchemaUpdateStrategy;
import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
import org.apache.cayenne.access.jdbc.reader.RowReaderFactory;
import org.apache.cayenne.access.translator.BatchTranslator;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.translator.SQLTemplateTranslator;
import org.apache.cayenne.access.translator.SelectTranslator;
@@ -69,9 +68,6 @@ public class DefaultDataNodeFactory implements DataNodeFactory {
@Inject
protected ProcedureTranslator procedureTranslator;
- @Inject
- protected EJBQLTranslator ejbqlTranslator;
-
@Inject
protected AdhocObjectFactory objectFactory;
@@ -98,7 +94,6 @@ public class DefaultDataNodeFactory implements DataNodeFactory {
dataNode.setDeleteBatchTranslator(deleteBatchTranslator);
dataNode.setSelectTranslator(selectTranslator);
dataNode.setProcedureTranslator(procedureTranslator);
- dataNode.setEjbqlTranslator(ejbqlTranslator);
dataNode.setSqlTemplateTranslator(sqlTemplateTranslator);
dataNode.setDataSource(dataSource);
diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V14.java b/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V14.java
index 742be182a..2bcb83bfb 100644
--- a/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V14.java
+++ b/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V14.java
@@ -36,7 +36,7 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Upgrades projects to version 14.
+ * Upgrades projects to version 14
*
* @since 5.0
*/
@@ -51,6 +51,7 @@ public final class UpgradeHandler_V14 implements UpgradeHandler {
public void processProjectDom(UpgradeContext upgradeUnit) {
updateDomainSchemaAndVersion(upgradeUnit);
updateDomainExtensionSchema(upgradeUnit, VALIDATION);
+ removeEjbqlInspection(upgradeUnit);
}
@Override
@@ -60,6 +61,26 @@ public final class UpgradeHandler_V14 implements UpgradeHandler {
updateExtensionSchema(upgradeUnit, DB_IMPORT);
updateInfoSchema(upgradeUnit);
convertSelectQueries(upgradeUnit);
+ removeEjbqlQueries(upgradeUnit);
+ }
+
+ private void removeEjbqlInspection(UpgradeContext upgradeUnit) {
+ String path = "/domain/*[local-name()='validation']/*[local-name()='exclude']"
+ + "[normalize-space(text())='EJBQL_QUERY_INVALID_SYNTAX']";
+ for (Element exclude : elements(upgradeUnit, path)) {
+ exclude.getParentNode().removeChild(exclude);
+ }
+ }
+
+ private void removeEjbqlQueries(UpgradeContext upgradeUnit) {
+ String path = "/data-map/*[local-name()='query'][@type='EJBQLQuery']";
+ for (Element query : elements(upgradeUnit, path)) {
+ query.getParentNode().removeChild(query);
+ upgradeUnit.recordChange("""
+ Query '%s' was removed from the DataMap, as EJBQL queries are no longer supported. \
+ Replace it with an ObjectSelect or ColumnSelect parsed from a String"""
+ .formatted(query.getAttribute("name")), true);
+ }
}
private void convertSelectQueries(UpgradeContext upgradeUnit) {
diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V8.java b/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V8.java
index 3295f1173..8581457d0 100644
--- a/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V8.java
+++ b/cayenne/src/main/java/org/apache/cayenne/configuration/upgrade/UpgradeHandler_V8.java
@@ -66,7 +66,7 @@ public final class UpgradeHandler_V8 implements UpgradeHandler {
String queryType = switch (factory) {
case "org.apache.cayenne.map.SelectQueryBuilder" -> QueryDescriptor.SELECT_QUERY;
case "org.apache.cayenne.map.SQLTemplateBuilder" -> QueryDescriptor.SQL_TEMPLATE;
- case "org.apache.cayenne.map.EjbqlBuilder" -> QueryDescriptor.EJBQL_QUERY;
+ case "org.apache.cayenne.map.EjbqlBuilder" -> "EJBQLQuery";
case "org.apache.cayenne.map.ProcedureQueryBuilder" -> QueryDescriptor.PROCEDURE_QUERY;
default -> throw new ConfigurationException("Unknown query factory: " + factory);
};
diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/xml/QueryDescriptorHandler.java b/cayenne/src/main/java/org/apache/cayenne/configuration/xml/QueryDescriptorHandler.java
index e16522491..919abe027 100644
--- a/cayenne/src/main/java/org/apache/cayenne/configuration/xml/QueryDescriptorHandler.java
+++ b/cayenne/src/main/java/org/apache/cayenne/configuration/xml/QueryDescriptorHandler.java
@@ -34,7 +34,6 @@ public class QueryDescriptorHandler extends NamespaceAwareNestedTagHandler {
private static final String QUERY_DESCRIPTOR_TAG = "query";
private static final String QUERY_SQL_TAG = "sql";
- private static final String QUERY_EJBQL_TAG = "ejbql";
private static final String QUERY_SELECT_TAG = "select";
private static final String QUERY_PREFETCH_TAG = "prefetch";
@@ -70,7 +69,6 @@ public class QueryDescriptorHandler extends NamespaceAwareNestedTagHandler {
this.sqlKey = attributes.getValue("adapter-class");
return true;
- case QUERY_EJBQL_TAG:
case QUERY_SELECT_TAG:
case QUERY_PREFETCH_TAG:
createPrefetchSemantics(attributes);
@@ -87,10 +85,6 @@ public class QueryDescriptorHandler extends NamespaceAwareNestedTagHandler {
queryBuilder.addSql(data, sqlKey);
break;
- case QUERY_EJBQL_TAG:
- queryBuilder.setEjbql(data);
- break;
-
case QUERY_SELECT_TAG:
queryBuilder.setSelect(data);
changed = true;
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/AutoAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
index 35a757370..19214108d 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
@@ -24,7 +24,6 @@ import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.jdbc.CSParameter;
import org.apache.cayenne.access.jdbc.PSParameter;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.translator.SelectTranslator;
import org.apache.cayenne.access.types.ExtendedTypeMap;
@@ -290,14 +289,6 @@ public class AutoAdapter implements DbAdapter {
return getAdapter();
}
- /**
- * @since 5.0
- */
- @Override
- public EJBQLTranslator getEjbqlTranslator() {
- return getAdapter().getEjbqlTranslator();
- }
-
@Override
public List<String> getSystemCatalogs() {
return getAdapter().getSystemCatalogs();
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/DbAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/DbAdapter.java
index ed49ef5ec..ca5b3fbb5 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/DbAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/DbAdapter.java
@@ -23,7 +23,6 @@ import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
import org.apache.cayenne.access.jdbc.CSParameter;
import org.apache.cayenne.access.jdbc.PSParameter;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.translator.SelectTranslator;
import org.apache.cayenne.access.types.ExtendedTypeMap;
@@ -318,21 +317,6 @@ public interface DbAdapter {
*/
DbAdapter unwrap();
- /**
- * Returns the {@link EJBQLTranslator} for EJBQL to SQL translation.
- *
- * @since 5.0
- */
- EJBQLTranslator getEjbqlTranslator();
-
- /**
- * @deprecated in favor of {@link #getEjbqlTranslator()}.
- */
- @Deprecated(since = "5.0", forRemoval = true)
- default EJBQLTranslator getEjbqlTranslatorFactory() {
- return getEjbqlTranslator();
- }
-
/**
* @return list of system catalogs
* @since 4.1
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/JdbcActionBuilder.java b/cayenne/src/main/java/org/apache/cayenne/dba/JdbcActionBuilder.java
index b9857d290..0897cc97b 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/JdbcActionBuilder.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/JdbcActionBuilder.java
@@ -21,12 +21,10 @@ package org.apache.cayenne.dba;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.jdbc.BatchAction;
-import org.apache.cayenne.access.jdbc.EJBQLAction;
import org.apache.cayenne.access.jdbc.ProcedureAction;
import org.apache.cayenne.access.jdbc.SQLTemplateAction;
import org.apache.cayenne.access.jdbc.SelectAction;
import org.apache.cayenne.query.BatchQuery;
-import org.apache.cayenne.query.EJBQLQuery;
import org.apache.cayenne.query.FluentSelect;
import org.apache.cayenne.query.ProcedureQuery;
import org.apache.cayenne.query.SQLAction;
@@ -78,12 +76,4 @@ public class JdbcActionBuilder implements SQLActionVisitor {
public SQLAction sqlAction(SQLTemplate<?> query) {
return new SQLTemplateAction(query, dataNode);
}
-
- /**
- * @since 3.0
- */
- @Override
- public SQLAction ejbqlAction(EJBQLQuery<?> query) {
- return new EJBQLAction(query, this, dataNode);
- }
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
index 4afb96d15..6820e713f 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
@@ -24,8 +24,6 @@ import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
import org.apache.cayenne.access.jdbc.CSParameter;
import org.apache.cayenne.access.jdbc.PSParameter;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
import org.apache.cayenne.access.translator.procedure.DefaultProcedureTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.translator.select.DefaultSelectTranslator;
@@ -77,7 +75,6 @@ public class JdbcAdapter implements DbAdapter {
protected boolean supportsBatchUpdates;
protected boolean supportsUniqueConstraints;
protected boolean supportsGeneratedKeys;
- protected EJBQLTranslator ejbqlTranslator;
protected boolean caseInsensitiveCollations;
@@ -102,7 +99,6 @@ public class JdbcAdapter implements DbAdapter {
this.quotingStrategy = createQuotingStrategy();
- this.ejbqlTranslator = createEJBQLTranslator();
this.nativeColumnTypes = indexBySqlType(createNativeTypes());
this.extendedTypes = new ExtendedTypeMap();
initExtendedTypes(defaultExtendedTypes, userExtendedTypes, extendedTypeFactories, valueObjectTypeRegistry);
@@ -214,19 +210,6 @@ public class JdbcAdapter implements DbAdapter {
extendedTypes.addFactory(new ValueObjectTypeFactory(extendedTypes, valueObjectTypeRegistry));
}
- /**
- * Creates and returns an {@link EJBQLTranslator} used to generate
- * visitors for EJBQL to SQL translations. This method should be overriden
- * by subclasses that need to customize EJBQL generation.
- *
- * @since 3.0
- */
- protected EJBQLTranslator createEJBQLTranslator() {
- JdbcEJBQLTranslator translatorFactory = new JdbcEJBQLTranslator();
- translatorFactory.setCaseInsensitive(caseInsensitiveCollations);
- return translatorFactory;
- }
-
/**
* Returns a generic PK generator based on the "AUTO_PK_SUPPORT" lookup table.
*/
@@ -668,18 +651,6 @@ public class JdbcAdapter implements DbAdapter {
this.supportsGeneratedKeys = flag;
}
- /**
- * Returns the {@link EJBQLTranslator} for EJBQL to SQL translation. It is normally initialized in the
- * constructor by calling {@link #createEJBQLTranslator()}, and can be changed later by calling
- * {@link #setEjbqlTranslator(EJBQLTranslator)}.
- *
- * @since 5.0
- */
- @Override
- public EJBQLTranslator getEjbqlTranslator() {
- return ejbqlTranslator;
- }
-
@Override
public List<String> getSystemCatalogs() {
return Collections.emptyList();
@@ -690,25 +661,6 @@ public class JdbcAdapter implements DbAdapter {
return Collections.emptyList();
}
- /**
- * Sets the {@link EJBQLTranslator} for EJBQL to SQL translation. This property is normally initialized in the
- * constructor by calling {@link #createEJBQLTranslator()}, so users would only override it if they need to
- * customize EJBQL translation.
- *
- * @since 5.0
- */
- public void setEjbqlTranslator(EJBQLTranslator ejbqlTranslator) {
- this.ejbqlTranslator = ejbqlTranslator;
- }
-
- /**
- * @deprecated in favor of {@link #setEjbqlTranslator(EJBQLTranslator)}.
- */
- @Deprecated(since = "5.0", forRemoval = true)
- public void setEjbqlTranslatorFactory(EJBQLTranslator ejbqlTranslator) {
- setEjbqlTranslator(ejbqlTranslator);
- }
-
protected QuotingStrategy createQuotingStrategy() {
return new DefaultQuotingStrategy('"', '"');
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
index 20a5820ac..a1da4d6ae 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
@@ -22,8 +22,6 @@ package org.apache.cayenne.dba.db2;
import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
import org.apache.cayenne.access.types.BooleanType;
import org.apache.cayenne.access.types.ByteArrayType;
import org.apache.cayenne.access.types.CharType;
@@ -187,16 +185,6 @@ public class DB2Adapter extends JdbcAdapter {
return new DB2SQLTreeProcessor();
}
- /**
- * @since 5.0
- */
- @Override
- public EJBQLTranslator getEjbqlTranslator() {
- JdbcEJBQLTranslator translator = new DB2EJBQLTranslator();
- translator.setCaseInsensitive(caseInsensitiveCollations);
- return translator;
- }
-
@Override
@SuppressWarnings("rawtypes")
protected void bind(PreparedStatement statement, Object value, int psPosition, int psType, int psScale,
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLConditionTranslator.java
deleted file mode 100644
index 5f3a18b34..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLConditionTranslator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.db2;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.parser.EJBQLTrimSpecification;
-
-/**
- * @since 4.0
- */
-public class DB2EJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- DB2EJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitTrim(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- if (!(expression.getChild(0) instanceof EJBQLTrimSpecification)) {
- context.append(" {fn TRIM(");
- }
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- }
-
- return true;
- }
-
- @Override
- public boolean visitTrimBoth(EJBQLExpression expression) {
- context.append(" {fn TRIM(");
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLTranslator.java
deleted file mode 100644
index 9b0b6606e..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/db2/DB2EJBQLTranslator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.db2;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 4.0
- */
-public class DB2EJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- context.setCaseInsensitive(caseInsensitive);
- return new DB2EJBQLConditionTranslator(context);
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
index d372ada3d..5809cffe9 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
@@ -21,8 +21,6 @@ package org.apache.cayenne.dba.derby;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
import org.apache.cayenne.access.types.ByteType;
import org.apache.cayenne.access.types.CharType;
import org.apache.cayenne.access.types.ExtendedType;
@@ -216,16 +214,6 @@ public class DerbyAdapter extends JdbcAdapter {
return new DerbySQLTreeProcessor();
}
- /**
- * @since 3.1
- */
- @Override
- protected EJBQLTranslator createEJBQLTranslator() {
- JdbcEJBQLTranslator translatorFactory = new DerbyEJBQLTranslator();
- translatorFactory.setCaseInsensitive(caseInsensitiveCollations);
- return translatorFactory;
- }
-
@Override
@SuppressWarnings("rawtypes")
protected void bind(PreparedStatement statement, Object value, int psPosition, int psType, int psScale,
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLConditionTranslator.java
deleted file mode 100644
index bfdcaab0c..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLConditionTranslator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.derby;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-/**
- * @since 3.1
- */
-public class DerbyEJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- public DerbyEJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitCurrentTimestamp(EJBQLExpression expression) {
- context.append(" CURRENT_TIMESTAMP");
- return false;
- }
-
- @Override
- public boolean visitConcat(EJBQLExpression expression, int finishedChildIndex) {
-
- // note that for CHAR columns, CONCAT would include padding ... Should
- // we use TRIM here?
- if (finishedChildIndex < 0) {
- context.append(" (");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")");
- } else {
- context.append(" ||");
- }
-
- return true;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLTranslator.java
deleted file mode 100644
index 31d6be619..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/derby/DerbyEJBQLTranslator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.derby;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 3.1
- */
-public class DerbyEJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- context.setCaseInsensitive(caseInsensitive);
- return new DerbyEJBQLConditionTranslator(context);
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdAdapter.java
index 6665db95c..02de14dd7 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdAdapter.java
@@ -22,7 +22,6 @@ package org.apache.cayenne.dba.firebird;
import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.types.ByteArrayType;
import org.apache.cayenne.access.types.CharType;
import org.apache.cayenne.access.types.ExtendedType;
@@ -138,14 +137,6 @@ public class FirebirdAdapter extends JdbcAdapter {
return new FirebirdSQLTreeProcessor();
}
- /**
- * @since 5.0
- */
- @Override
- public EJBQLTranslator getEjbqlTranslator() {
- return new FirebirdEJBQLTranslator();
- }
-
@Override
public SQLAction getAction(Query query, DataNode node) {
return query.createSQLAction(new FirebirdActionBuilder(node));
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLConditionTranslator.java
deleted file mode 100644
index 2582fff73..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLConditionTranslator.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.firebird;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.parser.EJBQLTrimSpecification;
-
-/**
- * @since 4.0
- */
-public class FirebirdEJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- public FirebirdEJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitTrim(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- if (!(expression.getChild(0) instanceof EJBQLTrimSpecification)) {
- context.append(" {fn TRIM(");
- }
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")}");
- }
-
- return true;
- }
-
- @Override
- public boolean visitTrimLeading(EJBQLExpression expression) {
- context.append(" {fn TRIM(LEADING FROM ");
- return false;
- }
-
- @Override
- public boolean visitTrimTrailing(EJBQLExpression expression) {
- context.append(" {fn TRIM(TRAILING FROM ");
- return false;
- }
-
- @Override
- public boolean visitTrimBoth(EJBQLExpression expression) {
- context.append(" {fn TRIM(");
- return false;
- }
-
- @Override
- public boolean visitLower(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn LOWER(");
- return true;
- } else {
- return super.visitLower(expression, finishedChildIndex);
- }
- }
-
- @Override
- public boolean visitLocate(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" {fn POSITION(");
- return true;
- } else {
- return super.visitLocate(expression, finishedChildIndex);
- }
- }
-
- @Override
- public boolean visitSubstring(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" SUBSTRING(");
- } else {
- if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(" AS INTEGER))");
- } else {
- if(finishedChildIndex == 0) {
- context.append(" FROM CAST(");
- } else if(finishedChildIndex == 1) {
- context.append(" AS INTEGER) FOR CAST(");
- }
- }
- }
-
- return true;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLTranslator.java
deleted file mode 100644
index d3afd2e30..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/firebird/FirebirdEJBQLTranslator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.firebird;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 4.0
- */
-public class FirebirdEJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- context.setCaseInsensitive(caseInsensitive);
- return new FirebirdEJBQLConditionTranslator(context);
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java
index fd4d0271a..23e0796c7 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2Adapter.java
@@ -22,8 +22,6 @@ package org.apache.cayenne.dba.h2;
import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
import org.apache.cayenne.access.types.ExtendedType;
import org.apache.cayenne.access.types.ExtendedTypeFactory;
import org.apache.cayenne.access.types.ExtendedTypeMap;
@@ -120,17 +118,6 @@ public class H2Adapter extends JdbcAdapter {
return new H2SQLTreeProcessor();
}
- /**
- * @return translator factory for EJBQL queries
- * @since 5.0
- */
- @Override
- protected EJBQLTranslator createEJBQLTranslator() {
- JdbcEJBQLTranslator translatorFactory = new H2EJBQLTranslator();
- translatorFactory.setCaseInsensitive(caseInsensitiveCollations);
- return translatorFactory;
- }
-
@Override
public SQLAction getAction(Query query, DataNode node) {
return query.createSQLAction(new H2ActionBuilder(node));
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLConditionTranslator.java
deleted file mode 100644
index 33cfcacf5..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLConditionTranslator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.h2;
-
-import java.sql.Types;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLMultiColumnOperand;
-import org.apache.cayenne.access.translator.ejbql.EJBQLPathTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.dba.hsqldb.HSQLDBAdapter;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.map.ObjAttribute;
-
-/**
- * @since 5.0
- */
-public class H2EJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- H2EJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- expression.visit(new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- H2EJBQLConditionTranslator.this.addMultiColumnOperand(operand);
- }
-
- @Override
- protected void processTerminatingAttribute(ObjAttribute attribute) {
- if (attribute.getDbAttribute().getType() == Types.CHAR) {
- context.append(' ').append(HSQLDBAdapter.TRIM_FUNCTION).append("(");
- super.processTerminatingAttribute(attribute);
- context.append(')');
- }
- else {
- super.processTerminatingAttribute(attribute);
- }
- }
- });
-
- return false;
- }
-}
\ No newline at end of file
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLTranslator.java
deleted file mode 100644
index 21d63eac2..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/h2/H2EJBQLTranslator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.h2;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 5.0
- */
-public class H2EJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- return new H2EJBQLConditionTranslator(context);
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java
index caf52bb8c..4248bfed9 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java
@@ -23,8 +23,6 @@ import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.types.CharType;
import org.apache.cayenne.access.types.ExtendedType;
@@ -136,16 +134,6 @@ public class HSQLDBAdapter extends JdbcAdapter {
return new HSQLDBProcedureTranslator();
}
- /**
- * @since 4.0
- */
- @Override
- protected EJBQLTranslator createEJBQLTranslator() {
- JdbcEJBQLTranslator translatorFactory = new HSQLEJBQLTranslator();
- translatorFactory.setCaseInsensitive(caseInsensitiveCollations);
- return translatorFactory;
- }
-
/**
* Generate fully-qualified name for 1.8 and on. Subclass generates
* unqualified name.
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLConditionTranslator.java
deleted file mode 100644
index 9635aed3a..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLConditionTranslator.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.hsqldb;
-
-import java.sql.Types;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLMultiColumnOperand;
-import org.apache.cayenne.access.translator.ejbql.EJBQLPathTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.map.ObjAttribute;
-
-/**
- * @since 4.0
- */
-public class HSQLEJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- HSQLEJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- expression.visit(new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- HSQLEJBQLConditionTranslator.this.addMultiColumnOperand(operand);
- }
-
- @Override
- protected void processTerminatingAttribute(ObjAttribute attribute) {
- if (attribute.getDbAttribute().getType() == Types.CHAR) {
- context.append(' ').append(HSQLDBAdapter.TRIM_FUNCTION).append("(");
- super.processTerminatingAttribute(attribute);
- context.append(')');
- }
- else {
- super.processTerminatingAttribute(attribute);
- }
- }
- });
-
- return false;
- }
-}
\ No newline at end of file
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLTranslator.java
deleted file mode 100644
index b7ba23cde..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLEJBQLTranslator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.hsqldb;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 4.0
- */
-public class HSQLEJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- return new HSQLEJBQLConditionTranslator(context);
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
index e38910d9e..b41393525 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
@@ -22,8 +22,6 @@ package org.apache.cayenne.dba.mysql;
import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
import org.apache.cayenne.access.translator.ProcedureTranslator;
import org.apache.cayenne.access.types.ByteArrayType;
import org.apache.cayenne.access.types.CharType;
@@ -277,16 +275,6 @@ public class MySQLAdapter extends JdbcAdapter {
};
}
- /**
- * @since 3.0
- */
- @Override
- protected EJBQLTranslator createEJBQLTranslator() {
- JdbcEJBQLTranslator translatorFactory = new MySQLEJBQLTranslator();
- translatorFactory.setCaseInsensitive(caseInsensitiveCollations);
- return translatorFactory;
- }
-
/**
* Overrides super implementation to explicitly set table engine to InnoDB
* if FK constraints are supported by this adapter.
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLConditionTranslator.java
deleted file mode 100644
index 96981e385..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLConditionTranslator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.mysql;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-/**
- * Customizes EJBQL conditions translation for MySQL.
- *
- * @since 3.0
- */
-class MySQLEJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- MySQLEJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitTrim(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex < 0) {
- context.append(" TRIM(");
- }
- else if (finishedChildIndex + 2 == expression.getChildrenCount()) {
- context.append(" FROM");
- }
- else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")");
- }
-
- return true;
- }
-
- @Override
- public boolean visitTrimCharacter(EJBQLExpression expression) {
- context.append(' ').append(expression.getText());
- return false;
- }
-
- @Override
- public boolean visitTrimLeading(EJBQLExpression expression) {
- context.append("LEADING");
- return false;
- }
-
- @Override
- public boolean visitTrimTrailing(EJBQLExpression expression) {
- context.append("TRAILING");
- return false;
- }
-
- @Override
- public boolean visitTrimBoth(EJBQLExpression expression) {
- context.append("BOTH");
- return false;
- }
-
- @Override
- public boolean visitLike(EJBQLExpression expression, int finishedChildIndex) {
- if (finishedChildIndex == 0) {
- if (checkNullParameter(expression, " IS NULL")) {
- return false;
- }
-
- if (expression.isNegated()) {
- context.append(" NOT");
- }
- context.append(" LIKE");
-
- if (context.isCaseInsensitive()) {
- context.append(" BINARY");
- }
- }
-
- return true;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLTranslator.java
deleted file mode 100644
index 053f387f2..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/mysql/MySQLEJBQLTranslator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.mysql;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 3.0
- */
-class MySQLEJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- context.setCaseInsensitive(caseInsensitive);
- return new MySQLEJBQLConditionTranslator(context);
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
index 7efa755c1..3408bff96 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
@@ -23,7 +23,6 @@ import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.types.ByteType;
import org.apache.cayenne.access.types.ExtendedType;
import org.apache.cayenne.access.types.ExtendedTypeFactory;
@@ -218,14 +217,6 @@ public class OracleAdapter extends JdbcAdapter {
return new OracleSQLTreeProcessor();
}
- /**
- * @since 3.0
- */
- @Override
- protected EJBQLTranslator createEJBQLTranslator() {
- return new OracleEJBQLTranslator();
- }
-
/**
* Installs appropriate ExtendedTypes as converters for passing values
* between JDBC and Java layers.
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLConditionTranslator.java
deleted file mode 100644
index 93feba431..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLConditionTranslator.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.oracle;
-
-import java.sql.Types;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLMultiColumnOperand;
-import org.apache.cayenne.access.translator.ejbql.EJBQLPathTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.parser.Node;
-import org.apache.cayenne.map.ObjAttribute;
-
-/**
- * @since 3.0
- */
-class OracleEJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- OracleEJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
-
- expression.visit(new EJBQLPathTranslator(context) {
-
- @Override
- protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
- OracleEJBQLConditionTranslator.this.addMultiColumnOperand(operand);
- }
-
- @Override
- protected void processTerminatingAttribute(ObjAttribute attribute) {
- if (attribute.getDbAttribute().getType() == Types.CHAR) {
- context.append(' ').append(OracleAdapter.TRIM_FUNCTION).append("(");
- super.processTerminatingAttribute(attribute);
- context.append(')');
- }
- else {
- super.processTerminatingAttribute(attribute);
- }
- }
- });
-
- return false;
- }
-
- /**
- * The order of arguments is inverted in Oracle.
- * LOCATE(substr, str) -> INSTR(str, substr)
- * @since 4.0
- */
- @Override
- public boolean visitLocate(EJBQLExpression expression, int finishedChildIndex) {
- if(finishedChildIndex < 0) {
- swapNodeChildren(expression, 0, 1);
- context.append(" INSTR(");
- } else if (finishedChildIndex + 1 == expression.getChildrenCount()) {
- context.append(")");
- swapNodeChildren(expression, 0, 1);
- } else {
- context.append(',');
- }
- return true;
- }
-
- /**
- * @since 4.0
- */
- private void swapNodeChildren(EJBQLExpression expression, int i, int j) {
- if(!(expression instanceof Node)) {
- return;
- }
- Node node = (Node)expression;
- Node tmp = node.jjtGetChild(i);
- node.jjtAddChild(node.jjtGetChild(j), i);
- node.jjtAddChild(tmp, j);
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLTranslator.java
deleted file mode 100644
index 1456d79e0..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleEJBQLTranslator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.oracle;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-/**
- * @since 3.0
- */
-class OracleEJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- return new OracleEJBQLConditionTranslator(context);
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java
index 4d12eb681..49158fb76 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java
@@ -23,7 +23,6 @@ import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.types.ByteArrayType;
import org.apache.cayenne.access.types.ByteType;
import org.apache.cayenne.access.types.CharType;
@@ -124,11 +123,6 @@ public class SQLServerAdapter extends JdbcAdapter {
return new DefaultQuotingStrategy('[', ']');
}
- @Override
- protected EJBQLTranslator createEJBQLTranslator() {
- return new SQLServerEJBQLTranslator();
- }
-
/**
* Returns the word "go".
*/
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLConditionTranslator.java
deleted file mode 100644
index 49cc468ef..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLConditionTranslator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.sqlserver;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-class SQLServerEJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- boolean isExists;
-
- public SQLServerEJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitSubselect(EJBQLExpression expression) {
- context.onSubselect();
- context.append(" (");
- expression.visit(new SQLServerEJBQLSubselectTranslator(context, isExists));
- context.append(')');
- isExists = false;
- return false;
- }
-
- @Override
- public boolean visitExists(EJBQLExpression expression) {
- isExists = true;
- context.append(" EXISTS");
- return true;
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLSubselectTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLSubselectTranslator.java
deleted file mode 100644
index a84a32c91..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLSubselectTranslator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.sqlserver;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLSelectTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-class SQLServerEJBQLSubselectTranslator extends EJBQLSelectTranslator {
-
- boolean isExists;
-
- SQLServerEJBQLSubselectTranslator(EJBQLTranslationContext context, boolean isExists) {
- super(context);
- this.isExists = isExists;
- }
-
- @Override
- public boolean visitSelectExpressions(EJBQLExpression expression) {
- if (isExists) {
- context.append(" * ");
- isExists = false;
- }
- else {
- super.visitSelectExpressions(expression);
- }
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLTranslator.java
deleted file mode 100644
index d2f5c654b..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerEJBQLTranslator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.sqlserver;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-class SQLServerEJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- return new SQLServerEJBQLConditionTranslator(context);
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
index ac68dde85..dcb0172c6 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
@@ -21,7 +21,6 @@ package org.apache.cayenne.dba.sybase;
import org.apache.cayenne.dba.NativeColumnType;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.EJBQLTranslator;
import org.apache.cayenne.access.types.ByteArrayType;
import org.apache.cayenne.access.types.ByteType;
import org.apache.cayenne.access.types.CharType;
@@ -96,14 +95,6 @@ public class SybaseAdapter extends JdbcAdapter {
return new DefaultQuotingStrategy('[', ']');
}
- /**
- * @since 3.0
- */
- @Override
- protected EJBQLTranslator createEJBQLTranslator() {
- return new SybaseEJBQLTranslator();
- }
-
/**
* Returns a {@link SybasePkGenerator}.
*/
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLConditionTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLConditionTranslator.java
deleted file mode 100644
index 038cad85b..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLConditionTranslator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.sybase;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-class SybaseEJBQLConditionTranslator extends EJBQLConditionTranslator {
-
- boolean isExists;
-
- public SybaseEJBQLConditionTranslator(EJBQLTranslationContext context) {
- super(context);
- }
-
- @Override
- public boolean visitSubselect(EJBQLExpression expression) {
- context.onSubselect();
- context.append(" (");
- expression.visit(new SybaseEJBQLSubselectTranslator(context, isExists));
- context.append(')');
- isExists = false;
- return false;
- }
-
- @Override
- public boolean visitExists(EJBQLExpression expression) {
- isExists = true;
- context.append(" EXISTS");
- return true;
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLSubselectTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLSubselectTranslator.java
deleted file mode 100644
index 483153811..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLSubselectTranslator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.sybase;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLSelectTranslator;
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-
-class SybaseEJBQLSubselectTranslator extends EJBQLSelectTranslator {
-
- boolean isExists;
-
- SybaseEJBQLSubselectTranslator(EJBQLTranslationContext context, boolean isExists) {
- super(context);
- this.isExists = isExists;
- }
-
- @Override
- public boolean visitSelectExpressions(EJBQLExpression expression) {
- if (isExists) {
- context.append(" * ");
- isExists = false;
- }
- else {
- super.visitSelectExpressions(expression);
- }
- return false;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLTranslator.java
deleted file mode 100644
index 10fb8907f..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/dba/sybase/SybaseEJBQLTranslator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.dba.sybase;
-
-import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext;
-import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslator;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-
-class SybaseEJBQLTranslator extends JdbcEJBQLTranslator {
-
- @Override
- public EJBQLExpressionVisitor getConditionTranslator(EJBQLTranslationContext context) {
- return new SybaseEJBQLConditionTranslator(context);
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java
deleted file mode 100644
index c62570989..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql;
-
-import org.apache.cayenne.ejbql.parser.EJBQLAggregateColumn;
-import org.apache.cayenne.ejbql.parser.EJBQLDecimalLiteral;
-import org.apache.cayenne.ejbql.parser.EJBQLFromItem;
-import org.apache.cayenne.ejbql.parser.EJBQLIntegerLiteral;
-import org.apache.cayenne.ejbql.parser.EJBQLJoin;
-import org.apache.cayenne.ejbql.parser.EJBQLPositionalInputParameter;
-
-/**
- * A noop implementation of the EJBQL visitor that returns same preset boolean value from
- * all methods. Intended for subclassing.
- *
- * @since 3.0
- */
-public class EJBQLBaseVisitor implements EJBQLExpressionVisitor {
-
- protected boolean continueFlag;
-
- public EJBQLBaseVisitor() {
- this(true);
- }
-
- public EJBQLBaseVisitor(boolean continueFlag) {
- this.continueFlag = continueFlag;
- }
-
- public boolean visitAbs(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitAbstractSchemaName(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitAdd(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitAggregate(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitAll(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitAnd(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitAny(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitAscending(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitAverage(EJBQLAggregateColumn expression) {
- return continueFlag;
- }
-
- public boolean visitBetween(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitBooleanLiteral(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitClassName(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitConcat(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitConstructor(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitConstructorParameter(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitConstructorParameters(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitCount(EJBQLAggregateColumn expression) {
- return continueFlag;
- }
-
- public boolean visitCurrentDate(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitCurrentTime(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitCurrentTimestamp(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitDecimalLiteral(EJBQLDecimalLiteral expression) {
- return continueFlag;
- }
-
- public boolean visitDelete(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitDescending(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitDbPath(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitDistinct(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitDivide(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitEquals(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitEscapeCharacter(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitExists(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitFrom(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitFromItem(EJBQLFromItem expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitGreaterOrEqual(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitGreaterThan(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitGroupBy(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitHaving(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitIdentificationVariable(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitIdentifier(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitIn(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitInnerFetchJoin(EJBQLJoin join) {
- return continueFlag;
- }
-
- public boolean visitInnerJoin(EJBQLJoin join) {
- return continueFlag;
- }
-
- public boolean visitIntegerLiteral(EJBQLIntegerLiteral expression) {
- return continueFlag;
- }
-
- public boolean visitIsEmpty(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitIsNull(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitLength(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitLessOrEqual(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitLessThan(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitLike(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitLocate(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitLower(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitMax(EJBQLAggregateColumn expression) {
- return continueFlag;
- }
-
- public boolean visitMemberOf(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitMin(EJBQLAggregateColumn expression) {
- return continueFlag;
- }
-
- public boolean visitMod(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitMultiply(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitNamedInputParameterForIn(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitNamedInputParameter(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitNegative(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitNot(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitNotEquals(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitOr(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitOrderBy(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitOrderByItem(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitOuterFetchJoin(EJBQLJoin join) {
- return continueFlag;
- }
-
- public boolean visitOuterJoin(EJBQLJoin join) {
- return continueFlag;
- }
-
- public boolean visitPath(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitPatternValue(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitPositionalInputParameterForIn(EJBQLPositionalInputParameter expression) {
- return continueFlag;
- }
-
- public boolean visitPositionalInputParameter(EJBQLPositionalInputParameter expression) {
- return continueFlag;
- }
-
- public boolean visitSelect(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitSelectClause(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitSelectExpression(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitSelectExpressions(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitSize(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitSqrt(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitStringLiteral(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitSubselect(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitSubstring(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitSubtract(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitSum(EJBQLAggregateColumn expression) {
- return continueFlag;
- }
-
- public boolean visitTok(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitTrim(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitTrimBoth(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitTrimCharacter(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitTrimLeading(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitTrimTrailing(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitUpdate(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitUpdateField(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitUpdateItem(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitUpdateValue(EJBQLExpression expression) {
- return continueFlag;
- }
-
- public boolean visitUpper(EJBQLExpression expression, int finishedChildIndex) {
- return continueFlag;
- }
-
- public boolean visitWhere(EJBQLExpression expression) {
- return continueFlag;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLCompiledExpression.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLCompiledExpression.java
deleted file mode 100644
index 21fcf2a4c..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLCompiledExpression.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql;
-
-import java.util.List;
-
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.SQLResult;
-import org.apache.cayenne.query.PrefetchTreeNode;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-/**
- * Represents an EJB QL expression "compiled" in the context of a certain mapping.
- *
- * @since 3.0
- */
-public interface EJBQLCompiledExpression {
-
- /**
- * Returns a tree representation of an EJBQL expression.
- */
- EJBQLExpression getExpression();
-
- /**
- * Returns a descriptor of the root of this expression such as entity being fetched or
- * updated.
- */
- ClassDescriptor getRootDescriptor();
-
- /**
- * Returns a ClassDescriptor for the id variable.
- */
- ClassDescriptor getEntityDescriptor(String identifier);
-
- /**
- * Returns a collection of relationships that joins identifier with a parent entity.
- * Returns null if the identifier corresponds to one of the query roots.
- */
- List<DbRelationship> getIncomingRelationships(String identifier);
-
- /**
- * Returns EJB QL source of the compiled expression if available.
- */
- String getSource();
-
- /**
- * Returns a mapping of the result set columns, or null if this is not a select
- * expression.
- */
- SQLResult getResult();
-
- /**
- * Returns prefetched columns tree for fetch joins.
- */
- PrefetchTreeNode getPrefetchTree();
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLException.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLException.java
deleted file mode 100644
index fa4e391c1..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql;
-
-import org.apache.cayenne.exp.ExpressionException;
-
-/**
- * An exception thrown on errors during parsing EJBQL statements.
- *
- * @since 3.0
- */
-public class EJBQLException extends ExpressionException {
-
- public EJBQLException() {
- super();
- }
-
- public EJBQLException(String messageFormat, Object... messageArgs) {
- super(messageFormat, messageArgs);
- }
-
- public EJBQLException(String messageFormat, String expressionString, Throwable th,
- Object... messageArgs) {
- super(messageFormat, expressionString, th, messageArgs);
- }
-
- public EJBQLException(String messageFormat, Throwable cause, Object... messageArgs) {
- super(messageFormat, cause, messageArgs);
- }
-
- public EJBQLException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpression.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpression.java
deleted file mode 100644
index 238ad651c..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpression.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql;
-
-/**
- * An abstract EJBQL expression interface.
- *
- * @since 3.0
- */
-public interface EJBQLExpression {
-
- /**
- * Accepts a visitor, calling appropriate visitor method. If the visitor method
- * returns true, visits all children, otherwise stops.
- */
- void visit(EJBQLExpressionVisitor visitor);
-
- /**
- * Returns a number of child operands of this expression node.
- */
- int getChildrenCount();
-
- /**
- * Returns a child expression node at the specified index.
- */
- EJBQLExpression getChild(int index);
-
- /**
- * Returns a text property of the node.
- */
- String getText();
-
- /**
- * Returns an optional boolean flag that negates the value of the expression.
- */
- boolean isNegated();
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java
deleted file mode 100644
index faef89a9b..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql;
-
-import org.apache.cayenne.ejbql.parser.EJBQLAggregateColumn;
-import org.apache.cayenne.ejbql.parser.EJBQLDecimalLiteral;
-import org.apache.cayenne.ejbql.parser.EJBQLFromItem;
-import org.apache.cayenne.ejbql.parser.EJBQLIntegerLiteral;
-import org.apache.cayenne.ejbql.parser.EJBQLJoin;
-import org.apache.cayenne.ejbql.parser.EJBQLPositionalInputParameter;
-
-/**
- * A visitor interface to inspect the EJBQL expression tree. Visit methods return
- * booleans, indicating whether the children of a given node should be visited.
- *
- * @since 3.0
- */
-public interface EJBQLExpressionVisitor {
-
- boolean visitAbs(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitAbstractSchemaName(EJBQLExpression expression);
-
- /**
- * Called on visiting "add" expression and also after visiting every expression child.
- *
- * @param expression an "add" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitAdd(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitAggregate(EJBQLExpression expression);
-
- boolean visitAll(EJBQLExpression expression);
-
- /**
- * Called on visiting "and" expression and also after visiting every expression child.
- *
- * @param expression an "and" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitAnd(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitAny(EJBQLExpression expression);
-
- boolean visitAscending(EJBQLExpression expression);
-
- boolean visitAverage(EJBQLAggregateColumn expression);
-
- /**
- * Called on visiting "between" expression and also after visiting every expression
- * child.
- *
- * @param expression an "between" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitBetween(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitBooleanLiteral(EJBQLExpression expression);
-
- boolean visitClassName(EJBQLExpression expression);
-
- boolean visitConcat(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitConstructor(EJBQLExpression expression);
-
- boolean visitConstructorParameter(EJBQLExpression expression);
-
- boolean visitConstructorParameters(EJBQLExpression expression);
-
- boolean visitCount(EJBQLAggregateColumn expression);
-
- boolean visitCurrentDate(EJBQLExpression expression);
-
- boolean visitCurrentTime(EJBQLExpression expression);
-
- boolean visitCurrentTimestamp(EJBQLExpression expression);
-
- boolean visitDecimalLiteral(EJBQLDecimalLiteral expression);
-
- boolean visitDelete(EJBQLExpression expression);
-
- boolean visitDescending(EJBQLExpression expression);
-
- boolean visitDistinct(EJBQLExpression expression);
-
- /**
- * Called on visiting "divide" expression and also after visiting every expression
- * child.
- *
- * @param expression an "divide" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitDivide(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting "equals" expression and also after visiting every expression
- * child.
- *
- * @param expression an "equals" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitEquals(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitEscapeCharacter(EJBQLExpression expression);
-
- boolean visitExists(EJBQLExpression expression);
-
- boolean visitFrom(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitFromItem(EJBQLFromItem expression, int finishedChildIndex);
-
- /**
- * Called on visiting ">=" expression and also after visiting every expression child.
- *
- * @param expression an ">=" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitGreaterOrEqual(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting ">=" expression and also after visiting every expression child.
- *
- * @param expression an ">=" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitGreaterThan(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitGroupBy(EJBQLExpression expression);
-
- boolean visitHaving(EJBQLExpression expression);
-
- boolean visitIdentificationVariable(EJBQLExpression expression);
-
- boolean visitIdentifier(EJBQLExpression expression);
-
- boolean visitIn(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitInnerFetchJoin(EJBQLJoin join);
-
- boolean visitInnerJoin(EJBQLJoin join);
-
- boolean visitIntegerLiteral(EJBQLIntegerLiteral expression);
-
- boolean visitIsEmpty(EJBQLExpression expression);
-
- boolean visitIsNull(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitLength(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting "<=" expression and also after visiting every expression child.
- *
- * @param expression an "<=" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitLessOrEqual(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting "<" expression and also after visiting every expression child.
- *
- * @param expression an "<" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitLessThan(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting "LIKE" expression and also after visiting every expression
- * child.
- *
- * @param expression an "LIKE" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitLike(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitLocate(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitLower(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitMax(EJBQLAggregateColumn expression);
-
- boolean visitMemberOf(EJBQLExpression expression);
-
- boolean visitMin(EJBQLAggregateColumn expression);
-
- boolean visitMod(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting "*" expression and also after visiting every expression child.
- *
- * @param expression an "*" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitMultiply(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * <p>This method is invoked from the processing of the
- * {@link org.apache.cayenne.ejbql.parser.EJBQLIn} in order to handle a query such
- * as;</p>
- *
- * <div><code>p.toArtist IN (:artists)</code></div>
- */
-
- boolean visitNamedInputParameterForIn(EJBQLExpression expression);
-
- boolean visitNamedInputParameter(EJBQLExpression expression);
-
- boolean visitNegative(EJBQLExpression expression);
-
- boolean visitNot(EJBQLExpression expression);
-
- /**
- * Called on visiting "!=" expression and also after visiting every expression child.
- *
- * @param expression an "!=" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitNotEquals(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting "or" expression and also after visiting every expression child.
- *
- * @param expression an "or" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitOr(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitOrderBy(EJBQLExpression expression);
-
- boolean visitOrderByItem(EJBQLExpression expression);
-
- boolean visitOuterFetchJoin(EJBQLJoin join);
-
- boolean visitOuterJoin(EJBQLJoin join);
-
- /**
- * Called on visiting "path" expression and also after visiting every expression
- * child.
- *
- * @param expression a "path" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitPath(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitDbPath(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitPatternValue(EJBQLExpression expression);
-
- /**
- * <p>This method is invoked from the processing of the
- * {@link org.apache.cayenne.ejbql.parser.EJBQLIn} in order to handle a query such
- * as;</p>
- *
- * <div><code>p.toArtist IN (?1)</code></div>
- */
-
- boolean visitPositionalInputParameterForIn(EJBQLPositionalInputParameter expression);
-
- boolean visitPositionalInputParameter(EJBQLPositionalInputParameter expression);
-
- boolean visitSelect(EJBQLExpression expression);
-
- boolean visitSelectClause(EJBQLExpression expression);
-
- boolean visitSelectExpression(EJBQLExpression expression);
-
- boolean visitSelectExpressions(EJBQLExpression expression);
-
- boolean visitSize(EJBQLExpression expression);
-
- boolean visitSqrt(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitStringLiteral(EJBQLExpression expression);
-
- boolean visitSubselect(EJBQLExpression expression);
-
- boolean visitSubstring(EJBQLExpression expression, int finishedChildIndex);
-
- /**
- * Called on visiting "subtract" expression and also after visiting every expression
- * child.
- *
- * @param expression an "subtract" node being visited.
- * @param finishedChildIndex "-1" when the expression node is visited for the first
- * time, before its children; otherwise this is an index of a child just
- * visited.
- */
- boolean visitSubtract(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitSum(EJBQLAggregateColumn expression);
-
- boolean visitTok(EJBQLExpression expression);
-
- boolean visitTrim(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitTrimBoth(EJBQLExpression expression);
-
- boolean visitTrimCharacter(EJBQLExpression expression);
-
- boolean visitTrimLeading(EJBQLExpression expression);
-
- boolean visitTrimTrailing(EJBQLExpression expression);
-
- boolean visitUpdate(EJBQLExpression expression);
-
- boolean visitUpdateField(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitUpdateItem(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitUpdateValue(EJBQLExpression expression);
-
- boolean visitUpper(EJBQLExpression expression, int finishedChildIndex);
-
- boolean visitWhere(EJBQLExpression expression);
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParser.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParser.java
deleted file mode 100644
index dd60df813..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParser.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql;
-
-import org.apache.cayenne.map.EntityResolver;
-
-/**
- * An abstract definition of EJBQL query parser. The actual parser implementing this
- * interface is generated from JavaCC grammar.
- *
- * @since 3.0
- */
-public interface EJBQLParser {
-
- /**
- * Parses a string EJB QL into an {@link EJBQLExpression}.
- */
- EJBQLExpression parse(String ejbqlStatement) throws EJBQLException;
-
- /**
- * Parses and compiles an expression for the EntityResolver.
- */
- EJBQLCompiledExpression compile(String ejbqlStatement, EntityResolver resolver)
- throws EJBQLException;
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParserFactory.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParserFactory.java
deleted file mode 100644
index f6a26669b..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/EJBQLParserFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql;
-
-/**
- * Creates {@link EJBQLParser} based on the system settings.
- *
- * @since 3.0
- */
-public class EJBQLParserFactory {
-
- // this is the parser generated by JJTree/JavaCC
- private static String DEFAULT_PARSER_CLASS = "org.apache.cayenne.ejbql.parser.EJBQL$EJBQLDefaultParser";
-
- private static Class parserClass;
-
- private static Class getParserClass() throws ClassNotFoundException {
- if (parserClass == null) {
- // for now support only the default parser. If needed it should be
- // easy to plug external parsers via a System property...
- parserClass = Class.forName(DEFAULT_PARSER_CLASS, true, Thread
- .currentThread()
- .getContextClassLoader());
- }
-
- return parserClass;
- }
-
- public static EJBQLParser getParser() throws EJBQLException {
- try {
- return (EJBQLParser) getParserClass().getDeclaredConstructor().newInstance();
- }
- catch (Exception e) {
- throw new EJBQLException("Error creating EJBQL parser", e);
- }
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/AggregateConditionNode.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/AggregateConditionNode.java
deleted file mode 100644
index 1e59fcd21..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/AggregateConditionNode.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql.parser;
-
-/**
- * Superclass of aggregated conditional nodes such as NOT, AND, OR.
- * Defines priority of operations, so that SQL can be supplied with brackets as needed
- *
- * @since 3.0
- */
-public abstract class AggregateConditionNode extends SimpleNode {
- //defining all priorities here so that it would be easy to compare them visually
- static final int NOT_PRIORITY = 10;
- static final int AND_PRIORITY = 20;
- static final int OR_PRIORITY = 30;
-
- public AggregateConditionNode(int id) {
- super(id);
- }
-
- /**
- * Returns priority of conditional operator.
- * This is used to decide whether brackets are needed in resulting SQL
- */
- public abstract int getPriority();
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/CompiledExpression.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/CompiledExpression.java
deleted file mode 100644
index 9126658de..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/CompiledExpression.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql.parser;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.SQLResult;
-import org.apache.cayenne.query.PrefetchTreeNode;
-import org.apache.cayenne.reflect.ClassDescriptor;
-
-/**
- * A compiled EJBQL expression.
- *
- * @since 3.0
- */
-class CompiledExpression implements EJBQLCompiledExpression {
-
- private String source;
- private String rootId;
- private Map<String, ClassDescriptor> descriptorsById;
- private Map<String, ObjRelationship> incomingById;
- private EJBQLExpression expression;
- private SQLResult result;
- private PrefetchTreeNode prefetchTree;
-
-
- public ClassDescriptor getEntityDescriptor(String idVariable) {
- if (idVariable == null) {
- return null;
- }
-
- return descriptorsById.get(Compiler.normalizeIdPath(idVariable));
- }
-
- public SQLResult getResult() {
- return result;
- }
-
- public ClassDescriptor getRootDescriptor() {
- return rootId != null ? getEntityDescriptor(rootId) : null;
- }
-
- public List<DbRelationship> getIncomingRelationships(String identifier) {
- ObjRelationship relationship = incomingById.get(identifier);
- if (relationship == null) {
- return Collections.emptyList();
- }
-
- return relationship.getDbRelationships();
- }
-
- public EJBQLExpression getExpression() {
- return expression;
- }
-
- public String getSource() {
- return source;
- }
-
- void setExpression(EJBQLExpression expression) {
- this.expression = expression;
- }
-
- void setDescriptorsById(Map<String, ClassDescriptor> descriptorsById) {
- this.descriptorsById = descriptorsById;
- }
-
- void setIncomingById(Map<String, ObjRelationship> incomingById) {
- this.incomingById = incomingById;
- }
-
- void setSource(String source) {
- this.source = source;
- }
-
- void setRootId(String rootId) {
- this.rootId = rootId;
- }
-
- void setResult(SQLResult resultSetMapping) {
- this.result = resultSetMapping;
- }
-
- public PrefetchTreeNode getPrefetchTree() {
- return prefetchTree;
- }
-
- public void setPrefetchTree(PrefetchTreeNode prefetchTree) {
- this.prefetchTree = prefetchTree;
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/Compiler.java b/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/Compiler.java
deleted file mode 100644
index 638ed28ae..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ejbql/parser/Compiler.java
+++ /dev/null
@@ -1,652 +0,0 @@
-/*****************************************************************
- * 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
- *
- * https://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.cayenne.ejbql.parser;
-
-import org.apache.cayenne.ejbql.EJBQLBaseVisitor;
-import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
-import org.apache.cayenne.ejbql.EJBQLException;
-import org.apache.cayenne.ejbql.EJBQLExpression;
-import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
-import org.apache.cayenne.exp.path.CayennePath;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.Entity;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.EntityResult;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.SQLResult;
-import org.apache.cayenne.query.PrefetchTreeNode;
-import org.apache.cayenne.reflect.ArcProperty;
-import org.apache.cayenne.reflect.AttributeProperty;
-import org.apache.cayenne.reflect.ClassDescriptor;
-import org.apache.cayenne.reflect.PropertyDescriptor;
-import org.apache.cayenne.reflect.PropertyVisitor;
-import org.apache.cayenne.reflect.ToManyProperty;
-import org.apache.cayenne.reflect.ToOneProperty;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Produces an {@link EJBQLCompiledExpression} out of an EJBQL expression tree.
- *
- * @since 3.0
- */
-class Compiler {
-
- // a flag indicating whether column expressions should be treated as result columns or
- // not.
- private boolean appendingResultColumns;
-
- private String rootId;
- private EntityResolver resolver;
- private Map<String, ClassDescriptor> descriptorsById;
- private Map<String, ObjRelationship> incomingById;
- private Collection<EJBQLPath> paths;
- private EJBQLExpressionVisitor fromItemVisitor;
- private EJBQLExpressionVisitor joinVisitor;
- private EJBQLExpressionVisitor pathVisitor;
- private EJBQLExpressionVisitor rootDescriptorVisitor;
- private List<Object> resultComponents;
- private PrefetchTreeNode prefetchTree = null;
-
- Compiler(EntityResolver resolver) {
- this.resolver = resolver;
- this.descriptorsById = new HashMap<>();
- this.incomingById = new HashMap<>();
-
- this.rootDescriptorVisitor = new SelectExpressionVisitor();
- this.fromItemVisitor = new FromItemVisitor();
- this.joinVisitor = new JoinVisitor();
- this.pathVisitor = new PathVisitor();
- }
-
- CompiledExpression compile(String source, EJBQLExpression parsed) {
- parsed.visit(new CompilationVisitor());
-
- Map<EJBQLPath, Integer> pathsInSelect = new HashMap<>();
-
- for (int i = 0; i < parsed.getChildrenCount(); i++) {
- if (parsed.getChild(i) instanceof EJBQLSelectClause) {
-
- EJBQLExpression parsedTemp = parsed.getChild(i);
- boolean stop = false;
-
- while (parsedTemp.getChildrenCount() > 0 && !stop) {
- EJBQLExpression newParsedTemp = null;
- for (int j = 0; j < parsedTemp.getChildrenCount(); j++) {
- if (parsedTemp.getChild(j) instanceof EJBQLSelectExpression) {
- for (int k = 0; k < parsedTemp
- .getChild(j)
- .getChildrenCount(); k++) {
-
- if (parsedTemp.getChild(j).getChild(k) instanceof EJBQLPath) {
- pathsInSelect.put((EJBQLPath) parsedTemp
- .getChild(j)
- .getChild(k), j);
-
- }
- }
- }
- else {
- if (parsedTemp.getChild(j).getChildrenCount() == 0) {
- stop = true;
- }
- else {
- newParsedTemp = parsedTemp.getChild(j);
- }
- }
- }
-
- if (!stop && newParsedTemp != null) {
- parsedTemp = newParsedTemp;
- }
- else {
- stop = true;
- }
- }
- }
- }
-
- // postprocess paths, now that all id vars are resolved
- if (paths != null) {
- for (EJBQLPath path : paths) {
- String id = normalizeIdPath(path.getId());
- ClassDescriptor descriptor = descriptorsById.get(id);
- if (descriptor == null) {
- throw new EJBQLException("Unmapped id variable: " + id);
- }
-
- StringBuilder buffer = new StringBuilder(id);
-
- ObjRelationship incoming = null;
- String pathRelationshipString = "";
-
- for (int i = 1; i < path.getChildrenCount(); i++) {
-
- String pathChunk = path.getChild(i).getText();
- if(pathChunk.endsWith(Entity.OUTER_JOIN_INDICATOR)) {
- pathChunk = pathChunk.substring(0, pathChunk.length() - 1);
- }
-
- buffer.append('.').append(pathChunk);
-
- PropertyDescriptor property = descriptor.getProperty(pathChunk);
-
- if (property instanceof ArcProperty) {
- incoming = ((ArcProperty) property).getRelationship();
- descriptor = ((ArcProperty) property).getTargetDescriptor();
- pathRelationshipString = buffer.substring(0, buffer.length());
-
- descriptorsById.put(pathRelationshipString, descriptor);
- incomingById.put(pathRelationshipString, incoming);
-
- }
- }
-
- if (pathsInSelect.size() > 0
- && incoming != null
- && pathRelationshipString.length() > 0
- && pathRelationshipString.equals(buffer.toString())) {
-
- EJBQLIdentifier ident = new EJBQLIdentifier(0);
- ident.text = pathRelationshipString;
-
- Integer integer = pathsInSelect.get(path);
- if (integer != null) {
- resultComponents.remove(integer.intValue());
- resultComponents.add(integer, ident);
- rootId = pathRelationshipString;
- }
- }
- }
- }
-
- CompiledExpression compiled = new CompiledExpression();
- compiled.setExpression(parsed);
- compiled.setSource(source);
-
- compiled.setRootId(rootId);
- compiled.setDescriptorsById(descriptorsById);
- compiled.setIncomingById(incomingById);
- compiled.setPrefetchTree(prefetchTree);
-
- if (resultComponents != null) {
- SQLResult mapping = new SQLResult();
-
- for (int i = 0; i < resultComponents.size(); i++) {
- Object nextMapping = resultComponents.get(i);
- if (nextMapping instanceof String) {
- mapping.addColumnResult((String) nextMapping);
- }
- else if (nextMapping instanceof EJBQLExpression) {
- EntityResult compileEntityResult = compileEntityResult(
- (EJBQLExpression) nextMapping,
- i);
- if (prefetchTree != null) {
- for (PrefetchTreeNode prefetch : prefetchTree.getChildren()) {
- if (((EJBQLExpression) nextMapping).getText().equals(
- prefetch.getEjbqlPathEntityId())) {
- EJBQLIdentifier ident = new EJBQLIdentifier(0);
- ident.text = prefetch.getEjbqlPathEntityId()
- + "."
- + prefetch.getPath();
-
- compileEntityResult = compileEntityResultWithPrefetch(
- compileEntityResult,
- ident);
-
- }
- }
- }
- mapping.addEntityResult(compileEntityResult);
-
- }
- }
-
- compiled.setResult(mapping);
-
- }
-
- return compiled;
- }
-
- private EntityResult compileEntityResultWithPrefetch(EntityResult compiledResult, EJBQLExpression prefetchExpression) {
- String id = prefetchExpression.getText().toLowerCase();
- ClassDescriptor descriptor = descriptorsById.get(id);
- if (descriptor == null) {
- descriptor = descriptorsById.get(prefetchExpression.getText());
- }
- String prefix = prefetchExpression.getText().substring(prefetchExpression.getText().indexOf(".") + 1);
- Set<String> visited = new HashSet<>();
-
- PropertyVisitor visitor = new PropertyVisitor() {
-
- public boolean visitAttribute(AttributeProperty property) {
- ObjAttribute oa = property.getAttribute();
... 15231 lines suppressed ...
(cayenne) 01/02: CAY-3039 Refactor Expressions to be independent from the parser syntax
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 276b766eb20b1df677b81c3306ce73e75afc3bf8
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun Sep 27 17:53:42 2026 -0400
CAY-3039 Refactor Expressions to be independent from the parser syntax
* operand vs child unification... don't wrap Objects in ScalarExp
---
.../main/java/org/apache/cayenne/exp/EnumRef.java | 94 ++++++++++++++++++++++
1 file changed, 94 insertions(+)
diff --git a/cayenne/src/main/java/org/apache/cayenne/exp/EnumRef.java b/cayenne/src/main/java/org/apache/cayenne/exp/EnumRef.java
new file mode 100644
index 000000000..ca19abb33
--- /dev/null
+++ b/cayenne/src/main/java/org/apache/cayenne/exp/EnumRef.java
@@ -0,0 +1,94 @@
+/*****************************************************************
+ * 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
+ *
+ * https://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.cayenne.exp;
+
+import java.util.Objects;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.util.Util;
+
+/**
+ * An enum constant referenced by the names of its class and constant, as parsed from the "enum:" literal of an
+ * expression String. It is resolved to the constant on access, so that an expression can be parsed and printed in an
+ * environment where the enum class is not available, e.g. in the Modeler.
+ *
+ * @since 5.0
+ */
+public final class EnumRef {
+
+ private final String className;
+ private final String enumName;
+
+ public EnumRef(String className, String enumName) {
+ this.className = Objects.requireNonNull(className);
+ this.enumName = Objects.requireNonNull(enumName);
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getEnumName() {
+ return enumName;
+ }
+
+ /**
+ * Loads the enum class and returns the referenced constant.
+ */
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public Enum<?> resolve() {
+ Class enumClass;
+ try {
+ enumClass = Util.getJavaClass(className);
+ } catch (ClassNotFoundException e) {
+ throw new CayenneRuntimeException("Enum class not found: " + className);
+ }
+
+ if (!enumClass.isEnum()) {
+ throw new CayenneRuntimeException("Specified class is not an enum: " + className);
+ }
+
+ try {
+ return Enum.valueOf(enumClass, enumName);
+ } catch (IllegalArgumentException e) {
+ throw new CayenneRuntimeException("Invalid enum path: " + className + "." + enumName);
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof EnumRef other)) return false;
+ return className.equals(other.className) && enumName.equals(other.enumName);
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * className.hashCode() + enumName.hashCode();
+ }
+
+ /**
+ * Returns the "enum:" literal of the constant, as it appears in an expression String.
+ */
+ @Override
+ public String toString() {
+ return "enum:" + className + "." + enumName;
+ }
+}