Skip to content

Commit

Permalink
Issue #1727 - Fixed missing default FQN entity alias name.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Kraus <tomas.kraus@oracle.com>
  • Loading branch information
Tomas-Kraus committed Oct 12, 2022
1 parent 140718f commit 9adb0a8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ public static Test suite() {
suite.addTest(new JUnitJPQLSimpleTest("testOrderByWithParenthesesCalculatedAndNormalDefault"));
suite.addTest(new JUnitJPQLSimpleTest("testOrderByWithParenthesesAllAttributes"));
suite.addTest(new JUnitJPQLSimpleTest("testOrderByWithParenthesesAllAttributesHybrid"));

// Issue #1727 - Error execution delete operation without identification_variable on FQN entity
suite.addTest(new JUnitJPQLSimpleTest("testDeleteFQNEntityNoAlias"));
suite.addTest(new JUnitJPQLSimpleTest("testDeleteFQNEntityAlias"));

return suite;
}

Expand Down Expand Up @@ -2632,5 +2635,43 @@ public void testOrderByWithParenthesesAllAttributesHybrid() {
closeEntityManager(em);
}
}


/**
* Test simple DELETE query with fully qualified entity class name and no alias.
*/
public void testDeleteFQEntityNoAlias() {
EntityManager em = createEntityManager();
beginTransaction(em);
try {
Query query = em.createQuery(
"DELETE FROM org.eclipse.persistence.testing.models.jpa.advanced.Employee " +
"WHERE firstName = :fName AND lastName = :lName");
query.setParameter("fName", "Peter");
query.setParameter("lName", "Parker");
query.executeUpdate();
} finally {
rollbackTransaction(em);
closeEntityManager(em);
}
}

/**
* Test simple DELETE query with fully qualified entity class name and an alias.
*/
public void testDeleteFQEntityAlias() {
EntityManager em = createEntityManager();
beginTransaction(em);
try {
Query query = em.createQuery(
"DELETE FROM org.eclipse.persistence.testing.models.jpa.advanced.Employee e " +
"WHERE e.firstName = :fName AND e.lastName = :lName");
query.setParameter("fName", "Peter");
query.setParameter("lName", "Parker");
query.executeUpdate();
} finally {
rollbackTransaction(em);
closeEntityManager(em);
}
}

}
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, 2022 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 Down Expand Up @@ -68,6 +68,7 @@ public void visit(CollectionMemberDeclaration expression) {
@Override
public void visit(CollectionValuedPathExpression expression) {
visitAbstractPathExpression(expression);
variableName = expression.toActualText().toLowerCase(Locale.ROOT);
}

@Override
Expand Down

0 comments on commit 9adb0a8

Please sign in to comment.