persistence@glassfish.java.net

RE: [Issue 154] New - EJBQL: bulk UPDATE statement should not update version columns

From: Peter Krogh <peter.krogh_at_oracle.com>
Date: Mon, 16 Jan 2006 10:14:15 -0500

Sorry I sent this too early ;)

I also meant to say - How do you compare the version fields in a Bulk Update?

I believe these two reasons are why the spec removed the version locking stuff from bulk updates.

However, you would get some protection if you just updated the version number and did not check the rowcount or the where clause version check. I think that is what we do right now. It protects against:

    - a bulk update followed by a regular update. (this will throw an optimistic lock exception)
It will not protect against:
    - two bulk updates one after the other.
    - a regular single object update followed by a bulk update.

However, I expect that the vast majority of users will be using bulk updates to do increment style changes (set every employees salary to sal * .05%, or age = age + 1 where birthday = today). These should still behave alright for the most part.


  -----Original Message-----
  From: Peter Krogh [mailto:peter.krogh_at_oracle.com]
  Sent: Monday, January 16, 2006 9:52 AM
  To: persistence_at_glassfish.dev.java.net
  Cc: Michael.Bouschen_at_Sun.COM
  Subject: RE: [Issue 154] New - EJBQL: bulk UPDATE statement should not update version columns


  I imagine the reason why this was removed from the spec is because of the row count. How do you know if you should throw an optimistic lock exception since you don't know how many objects were modified?


    -----Original Message-----
    From: Craig.Russell_at_Sun.COM [mailto:Craig.Russell_at_Sun.COM]On Behalf Of Craig L Russell
    Sent: Friday, January 13, 2006 8:25 PM
    To: persistence_at_glassfish.dev.java.net
    Cc: Michael.Bouschen_at_Sun.COM
    Subject: Re: [Issue 154] New - EJBQL: bulk UPDATE statement should not update version columns


    Hi,


    I'd suggest waiting to hear from the spec lead(s) before doing anything with this bug report. I understand that this is a spec bug.


    Craig


    On Jan 13, 2006, at 12:11 PM, Marina Vatkina wrote:


      Hi Michael,


      Isn't the spec requirement wrong? While it might be
      tricky to update version column of all tables, if
      bulk update doesn't do it, any parallel tx can override the changes.


      thanks,
      -marina


      ----- Original Message -----
      From: mb124283_at_dev.java.net
      Date: Friday, January 13, 2006 11:11 am
      Subject: [Issue 154] New - EJBQL: bulk UPDATE statement should not update version columns


        https://glassfish.dev.java.net/issues/show_bug.cgi?id=154
        Issue #|154
        Summary|EJBQL: bulk UPDATE statement should not
        update version
        | columns
        Component|glassfish
        Version|9.0pe
        Platform|All
        OS/Version|All
        URL|
        Status|NEW
        Status whiteboard|
        Keywords|
        Resolution|
        Issue type|TASK
        Priority|P3
        Subcomponent|entity-persistence
        Assigned to|tware
        Reported by|mb124283












        ------- Additional comments from mb124283_at_dev.java.net Fri Jan 13
        19:11:47 +0000 2006 -------
        The PFD version of the EJB3 persistence spec clarifies that an
        EJBQL bulk UPDATE
        statement does not update version columns.


        Today the EJBQL query
        UPDATE Customer c SET c.name = 'CHANGED'
        is mapped to the following SQL:
        UPDATE CMP3_CUSTOMER
        SET NAME = 'CHANGED', CUST_VERSION = (CUST_VERSION + 1)


        --------------------------------------------------------------------
        -
        To unsubscribe, e-mail: issues-unsubscribe_at_glassfish.dev.java.net
        For additional commands, e-mail: issues-help_at_glassfish.dev.java.net






    Craig Russell

    Architect, Sun Java Enterprise System http://java.sun.com/products/jdo

    408 276-5638 mailto:Craig.Russell_at_sun.com

    P.S. A good JDO? O, Gasp!