[ 
https://issues.apache.org/jira/browse/OPENJPA-3094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148317#comment-18148317
 ] 

ASF subversion and git services commented on OPENJPA-3094:
----------------------------------------------------------

Commit 4b5d34c64f2620d6a41c6d53638ce3005c25e292 in openjpa's branch 
refs/heads/OPENJPA-3094 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=4b5d34c64 ]

[OPENJPA-3094] Run a single table bulk delete or update without a subquery on 
Derby and PostgreSQL

Derby and PostgreSQL do not allow an alias in the SET clause of an UPDATE,
so their dictionaries set allowsAliasInBulkClause to false. That also sent
every bulk delete and update with a WHERE clause through the
ID IN (SELECT DISTINCT ...) form, even when the condition only reads the
table of the statement. Both databases accept an alias on the table of a
DELETE or UPDATE that the WHERE clause uses. The new dictionary property
allowsTargetAliasInBulkClause lets such a statement name its table with
the alias and keep the SET columns unqualified, when the WHERE clause has
no subquery. Statements that join other tables keep the subquery.


> 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
>            Priority: Major
>             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)
  • [jira] [Commented] (OPENJPA... ASF subversion and git services (Jira) via dev

Reply via email to