Skip to content

Commit

Permalink
Jakarta Persistence 3.2 new feature - JPQL UNION, INTERSECT, EXCEPT, …
Browse files Browse the repository at this point in the history
…CAST (#1937)

This change doesn't create anything new as specified operators/functions were already specified as a part of EclipseLink JPQL extensions from 2.4 version.
There is refactoring/movement of affected code related with `org.eclipse.persistence.jpa.jpql.parser.CastExpression`, `org.eclipse.persistence.jpa.jpql.parser.DatabaseType`, `org.eclipse.persistence.jpa.jpql.parser.UnionClause` from `EclipseLink...` classes to default JPQL classes.
Due this movement all specified operators/functions are available from Jakarta Persistence/JPQL Grammar 3.2 and still from EclipseLink JPQL extensions 2.4.

EclipseLink issue is described at #1885 and Jakarta Persistence specification request at the jakartaee/persistence#395 (cast) and jakartaee/persistence#398 (union, intersect, and except)

Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
  • Loading branch information
rfelcman committed Sep 14, 2023
1 parent abe7bf9 commit f7070a1
Show file tree
Hide file tree
Showing 31 changed files with 1,443 additions and 535 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2015 SAP. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -187,7 +187,7 @@ public void testNegativ() {
boolean operationFailed = false;
env.beginTransaction(em);
try {
employee = em.getReference(Employee.class, 17 + 4);
employee = em.getReference(Employee.class, 741);
} catch (EntityNotFoundException e) {
// $JL-EXC$ expected behavior
operationFailed = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -16,9 +16,7 @@
package org.eclipse.persistence.jpa.jpql;

import org.eclipse.persistence.jpa.jpql.parser.AsOfClause;
import org.eclipse.persistence.jpa.jpql.parser.CastExpression;
import org.eclipse.persistence.jpa.jpql.parser.ConnectByClause;
import org.eclipse.persistence.jpa.jpql.parser.DatabaseType;
import org.eclipse.persistence.jpa.jpql.parser.EclipseLinkExpressionVisitor;
import org.eclipse.persistence.jpa.jpql.parser.Expression;
import org.eclipse.persistence.jpa.jpql.parser.ExtractExpression;
Expand All @@ -28,7 +26,6 @@
import org.eclipse.persistence.jpa.jpql.parser.StartWithClause;
import org.eclipse.persistence.jpa.jpql.parser.TableExpression;
import org.eclipse.persistence.jpa.jpql.parser.TableVariableDeclaration;
import org.eclipse.persistence.jpa.jpql.parser.UnionClause;

/**
* This visitor calculates the type of an input parameter.
Expand Down Expand Up @@ -57,21 +54,11 @@ public void visit(AsOfClause expression) {
type = Object.class;
}

@Override
public void visit(CastExpression expression) {
type = Object.class;
}

@Override
public void visit(ConnectByClause expression) {
type = Object.class;
}

@Override
public void visit(DatabaseType expression) {
type = Object.class;
}

@Override
public void visit(ExtractExpression expression) {
type = Object.class;
Expand Down Expand Up @@ -115,9 +102,4 @@ public void visit(TableExpression expression) {
public void visit(TableVariableDeclaration expression) {
type = Object.class;
}

@Override
public void visit(UnionClause expression) {
type = Object.class;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -19,7 +19,6 @@
import org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor;
import org.eclipse.persistence.jpa.jpql.parser.AsOfClause;
import org.eclipse.persistence.jpa.jpql.parser.BadExpression;
import org.eclipse.persistence.jpa.jpql.parser.CastExpression;
import org.eclipse.persistence.jpa.jpql.parser.CollectionExpression;
import org.eclipse.persistence.jpa.jpql.parser.CollectionValuedPathExpression;
import org.eclipse.persistence.jpa.jpql.parser.ConnectByClause;
Expand All @@ -40,7 +39,6 @@
import org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression;
import org.eclipse.persistence.jpa.jpql.parser.TableExpression;
import org.eclipse.persistence.jpa.jpql.parser.TableVariableDeclaration;
import org.eclipse.persistence.jpa.jpql.parser.UnionClause;

import static org.eclipse.persistence.jpa.jpql.JPQLQueryProblemMessages.*;

Expand Down Expand Up @@ -109,11 +107,6 @@ protected LiteralVisitor buildLiteralVisitor() {
return new EclipseLinkLiteralVisitor();
}

@Override
protected OwningClauseVisitor buildOwningClauseVisitor() {
return new EclipseLinkOwningClauseVisitor();
}

protected SubquerySelectItemCalculator buildSubquerySelectItemCalculator() {
return new SubquerySelectItemCalculator();
}
Expand Down Expand Up @@ -391,12 +384,6 @@ public void visit(AsOfClause expression) {
// Nothing to validate semantically
}

@Override
public void visit(CastExpression expression) {
super.visit(expression);
// Nothing to validate semantically
}

@Override
public void visit(ConnectByClause expression) {
super.visit(expression);
Expand Down Expand Up @@ -464,38 +451,6 @@ public void visit(TableVariableDeclaration expression) {
// Nothing to validate semantically
}

@Override
public void visit(UnionClause expression) {
super.visit(expression);
// Nothing to validate semantically
}

// Made static final for performance reasons.
/**
* This visitor retrieves the clause owning the visited {@link Expression}.
*/
public static final class EclipseLinkOwningClauseVisitor extends OwningClauseVisitor {

public UnionClause unionClause;

/**
* Creates a new <code>EclipseLinkOwningClauseVisitor</code>.
*/
public EclipseLinkOwningClauseVisitor() {
super();
}

@Override
public void dispose() {
super.dispose();
unionClause = null;
}

public void visit(UnionClause expression) {
this.unionClause = expression;
}
}

// Made static final for performance reasons.
protected static final class SubquerySelectItemCalculator extends AnonymousExpressionVisitor {

Expand Down

0 comments on commit f7070a1

Please sign in to comment.