diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/jpa/jpql/JPQLFunctionsAbstractBuilder.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/jpa/jpql/JPQLFunctionsAbstractBuilder.java index ac0dbb9f06..1c8bb66c19 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/jpa/jpql/JPQLFunctionsAbstractBuilder.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/jpa/jpql/JPQLFunctionsAbstractBuilder.java @@ -28,14 +28,10 @@ import java.util.List; /** - * JPQL exclusive ID(), VERSION() functions/expressions are transformed there to - * StateFieldPathExpression. - * It should be used in the future for another JPQL functions/expressions which - * are not available at the DB level. - * E.g. For Entity e with idAttr as a primary key: - * SELECT ID(e) FROM Entity e -> SELECT e.idAttr FROM Entity e - * For Entity e with versionAttr as a version attribute: - * SELECT VERSION(e) FROM Entity e -> SELECT e.versionAttr FROM Entity e + * JPQL exclusive ID(), VERSION() functions/expressions are transformed there to StateFieldPathExpression. + * It should be used in the future for another JPQL functions/expressions which are not available at the DB level. + * E.g. For Entity e with idAttr as a primary key: SELECT ID(e) FROM Entity e -> SELECT e.idAttr FROM Entity e + * For Entity e with versionAttr as a version attribute: SELECT VERSION(e) FROM Entity e -> SELECT e.versionAttr FROM Entity e * * @author Radek Felcman * @since 5.0 @@ -43,8 +39,7 @@ public abstract class JPQLFunctionsAbstractBuilder extends EclipseLinkAnonymousExpressionVisitor { /** - * The {@link JPQLQueryContext} is used to query information about the - * application metadata and + * The {@link JPQLQueryContext} is used to query information about the application metadata and * cached information. */ final JPQLQueryContext queryContext; @@ -54,27 +49,20 @@ protected JPQLFunctionsAbstractBuilder(JPQLQueryContext queryContext) { } /** - * For Entity e with idAttr as a primary key: - * SELECT ID(e) FROM Entity e -> SELECT e.idAttr FROM Entity e + * For Entity e with idAttr as a primary key: SELECT ID(e) FROM Entity e -> SELECT e.idAttr FROM Entity e * * @param expression The {@link IdExpression} to visit */ @Override public void visit(IdExpression expression) { - System.out.println("INSIDE VISIT *******"); + //Fetch identification variable info IdentificationVariable identificationVariable = (IdentificationVariable) expression.getExpression(); String variableText = identificationVariable.getText(); String variableName = identificationVariable.getVariableName(); - // Get id attribute name + + //Get id attribute name ClassDescriptor descriptor = this.queryContext.getDeclaration(variableName).getDescriptor(); - List primaryKeyFields = descriptor.getPrimaryKeyFields(); - // String idAttributeName = getIdAttributeNameByField(descriptor.getMappings(), - // primaryKeyFields.get(0)); - // StateFieldPathExpression stateFieldPathExpression = new - // StateFieldPathExpression(expression.getParent(), variableText + "." + - // idAttributeName); - // expression.setStateFieldPathExpression(stateFieldPathExpression); - // expression.getStateFieldPathExpression().accept(this); + List primaryKeyFields = descriptor.getPrimaryKeyFields() if (!isEmbeddable(descriptor.getMappings())) { for (DatabaseField primaryKeyField : primaryKeyFields) { String idAttributeName = getIdAttributeNameByField(descriptor.getMappings(), primaryKeyField); @@ -98,27 +86,24 @@ public void visit(IdExpression expression) { } /** - * For Entity e with versionAttr as a version attribute: - * SELECT VERSION(e) FROM Entity e -> SELECT e.versionAttr FROM Entity e + * For Entity e with versionAttr as a version attribute: SELECT VERSION(e) FROM Entity e -> SELECT e.versionAttr FROM Entity e * * @param expression The {@link VersionExpression} to visit */ @Override public void visit(VersionExpression expression) { - // Fetch identification variable info + //Fetch identification variable info IdentificationVariable identificationVariable = (IdentificationVariable) expression.getExpression(); String variableText = identificationVariable.getText(); String variableName = identificationVariable.getVariableName(); - // Get version attribute name + //Get version attribute name ClassDescriptor descriptor = this.queryContext.getDeclaration(variableName).getDescriptor(); - String versionAttributeName = ((VersionLockingPolicy) descriptor.getOptimisticLockingPolicy()) - .getVersionMapping().getAttributeName(); - StateFieldPathExpression stateFieldPathExpression = new StateFieldPathExpression(expression.getParent(), - variableText + "." + versionAttributeName); + String versionAttributeName = ((VersionLockingPolicy) descriptor.getOptimisticLockingPolicy()).getVersionMapping().getAttributeName(); + StateFieldPathExpression stateFieldPathExpression = new StateFieldPathExpression(expression.getParent(), variableText + "." + versionAttributeName); expression.setStateFieldPathExpression(stateFieldPathExpression); - // Continue with created StateFieldPathExpression + //Continue with created StateFieldPathExpression expression.getStateFieldPathExpression().accept(this); }