geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gianny Damour (JIRA)" <...@geronimo.apache.org>
Subject [jira] Closed: (GERONIMO-1080) CMP generates invalid update SQL
Date Wed, 19 Oct 2005 02:14:44 GMT
     [ http://issues.apache.org/jira/browse/GERONIMO-1080?page=all ]
     
Gianny Damour closed GERONIMO-1080:
-----------------------------------

    Fix Version: 1.0
     Resolution: Fixed

This is now fixed.

Also, I do not think that the "CASE..WHEN..THEN..ELSE..END" approach is "pretty nasty".

This approach allows to send across to the database only the values when they have been updated.
Basically, when a field has not been updated, only the boolean false and null are sent.

Also, I do not think that a simple "foo=?, bar=?" approach is good: it implies that we generate
dynamically the UPDATE statements (to only update the fields which have changed). This is
usually a performance or resource problem (e.g. UPDATE statement caching on the database side).

> CMP generates invalid update SQL
> --------------------------------
>
>          Key: GERONIMO-1080
>          URL: http://issues.apache.org/jira/browse/GERONIMO-1080
>      Project: Geronimo
>         Type: Bug
>   Components: OpenEJB
>     Versions: 1.0-M5
>     Reporter: Aaron Mulder
>     Assignee: Gianny Damour
>      Fix For: 1.0

>
> I have a group of about 5 CMP EJBs, with various relationships defined.  I'm using PostgreSQL
8.  I'm not able to update (well, at least, the two EJBs I've tried have both had the problem).
 I get this error:
> java.sql.SQLException: ERROR: multiple assignments to same column "test_id"
> And indeed the SQL is:
> UPDATE test_run SET test_id = CASE WHEN ? THEN ? ELSE test_id END, create_date = CASE
WHEN ? THEN ? ELSE create_date END, name = CASE WHEN ? THEN ? ELSE name END, description =
CASE WHEN ? THEN ? ELSE description END, test_id = CASE WHEN ? THEN ? ELSE test_id END WHERE
id = ?
> Likewise, for a different table:
> UPDATE test_run_machine SET test_run_id = CASE WHEN ? THEN ? ELSE test_run_id END, machine_id
= CASE WHEN ? THEN ? ELSE machine_id END, role = CASE WHEN ? THEN ? ELSE role END, time_offset_ms
= CASE WHEN ? THEN ? ELSE time_offset_ms END, test_run_id = CASE WHEN ? THEN ? ELSE test_run_id
END, machine_id = CASE WHEN ? THEN ? ELSE machine_id END WHERE id = ?
> I speculate that it's noticing the columns once as CMP fields and once as CMR fields,
or perhaps pulling them in twice if the EJB participates in two relationships (even though
they wouldn't both use that field) or something.  In any case, we should always eliminate
duplicates, as far as I can tell.
> Also, the CASE..WHEN..THEN..ELSE..END statements seem pretty nasty to me.  Why don't
we just do "update foo set bar=?, baz=?,..."?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message