Update + Exists doesn't seem to work

Description

Don't know if this is me or not but this query doesn't seem to work with the many to many relationship between reservation and customer:

Query query;
query = manager.createQuery("UPDATE Reservation res " +
"SET res.amountPaid = (res.amountPaid + 10) " +
"WHERE EXISTS (" +
"SELECT c FROM res.customers c " +
"where c.firstName = 'Bill' and " +
"c.lastName='Burke')");
query.executeUpdate();

Attachments

1

Activity

Show:

Steve Ebersole March 21, 2011 at 6:59 PM

Closing stale resolved issues

Georgios Skempes March 30, 2006 at 9:22 AM

Hello Steve,

I think this fix may cause the problem I have reported for Version 3.1.3. Can you please cross-check?

Kind regards,
Georgios

Steve Ebersole February 13, 2006 at 6:58 PM

This is fixed for all execution paths that go through FromElementType.toColumns(...) to generate the proper column qualifications. I cannot guarentee though that there are not one-off places throughout the parser codebase that render the columns themselves; we'll need to find them on a case-by-case basis. At any rate all test cases pass (including the new ones to test this stuff specifically).

Steve Ebersole February 12, 2006 at 8:13 PM

Actually, this is still a problem. The underlying issue is that the qualified column fragment needs to be different based on whether we are doing a a single delete/update versus a multi-table delete/update. And unfortunately, at the time that this rendering currently happens we do not yet know which style we will need.

Two options to properly fix this:
1) Hack it such that when rendering columns, we "look ahead" to so if this bulk statement will result in a multi-table update/delete; not sure this is even possible in all cases.
2) Delay rendering of the SQL fragments until we actually generate the SQL statement (sql.g); this is the correct fix, but intensive to fix.

GavinG January 29, 2006 at 11:22 PM

Yes, that is a bug. The columns should be qualified.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created January 29, 2006 at 7:53 AM
Updated March 21, 2011 at 6:59 PM
Resolved February 13, 2006 at 6:58 PM