[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2408) Incorrect SQL generated for JPA QL Update statement involving multiple entities
Gail Badner (JIRA)
noreply at atlassian.com
Wed Mar 28 19:57:04 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_26584 ]
Gail Badner commented on HHH-2408:
----------------------------------
This query is for a bulk update. HQL for bulk updates is covered in http://www.hibernate.org/hib_docs/v3/reference/en/html/batch.html#batch-direct . This section states that there is a limitation on this type of query that only sub-queries can contain joins.
In the query:
UPDATE Issue i SET i.dueDate = i.dueDate + 10 WHERE i.visit.branch.id = :branchId
there is an implicit join between the issue and visit tables. This join would need to be put in a sub-query, for example:
UPDATE Issue i SET i.dueDate = i.dueDate + 10
WHERE EXISTS(SELECT 1 FROM Visit v WHERE i.visit = v AND v.branch.id = :branchId)
I tried this in the attached test case and it seemed to work.
Gail Badner
SourceLabs - http://www.sourcelabs.com
Dependable Open Source Systems
> Incorrect SQL generated for JPA QL Update statement involving multiple entities
> -------------------------------------------------------------------------------
>
> Key: HHH-2408
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2408
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.2.2
> Environment: Hibernate 3.2.2 GA, Oracle 9i
> Reporter: Alex Savitsky
> Attachments: application.properties, Branch.java, Issue.java, log.txt, PersistentEntity.java, TestCase.zip, Visit.java
>
>
> When generating SQL for statements like this: UPDATE Issue i SET i.dueDate = i.dueDate + 10 WHERE i.visit.branch.id = :branchId, an extra comma is generated at the end of table list: update Issue, set DUE_DATE=DUE_DATE+10 where BRANCH_ID=?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list