Richard Zowalla created OPENJPA-3094:
----------------------------------------
Summary: Bulk delete and update use a subquery for a single table
on PostgreSQL and Derby
Key: OPENJPA-3094
URL: https://issues.apache.org/jira/browse/OPENJPA-3094
Project: OpenJPA
Issue Type: Improvement
Reporter: Richard Zowalla
Assignee: Richard Zowalla
Fix For: 4.3.0
A JPQL bulk DELETE or UPDATE whose WHERE clause only refers to the target table
is written with a subquery on PostgreSQL and Derby:
{noformat}
DELETE FROM ORDERS WHERE ID IN (SELECT DISTINCT t0.ID FROM ORDERS t0 WHERE
(t0.ID >= ? AND t0.ID <= ?))
{noformat}
DBDictionary.toBulkOperation() only writes the statement directly on the table
when allowsAliasInBulkClause is true. PostgresDictionary and DerbyDictionary
set it to false because PostgreSQL does not accept alias-qualified columns in
UPDATE ... SET, but both accept an alias on the target table that is only used
in WHERE:
{noformat}
DELETE FROM ORDERS t0 WHERE (t0.ID >= ? AND t0.ID <= ?)
{noformat}
Add a dictionary property for this case and use it on PostgreSQL and Derby.
Statements with joins, secondary tables or subqueries keep the current form.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)