Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1727 - Fixed missing default FQN entity alias name. #1729

Merged
merged 2 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"));
Tomas-Kraus marked this conversation as resolved.
Show resolved Hide resolved

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 testDeleteFQNEntityNoAlias() {
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 testDeleteFQNEntityAlias() {
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