conditional update is executed even if condition is false

From: Lothar Krenzien (lkrenzie..eb.de)
Date: Tue Nov 15 2005 - 04:35:10 EST

  • Next message: Ahmed Mohombe: "DataViews Status?"

    Hi there,

    I have a method called like 'updateXXX' which should update two tables. In the second one there is column which I would like to update only when the value of the corresponding java field is not empty. But it seems that this column is alsways updatet by cayenne !?

    //Java code
    ...
    TblPlant plant = (TblPlant) DataObjectUtils.objectForPK(context, TblPlant.class, Integer.parseInt(plantId));
    if(plant == null)
    throw new DataNotFoundException("plant not found");

    ...

    TblLogger logger = (TblLogger) DataObjectUtils.objectForPK(context, TblLogger.class, Integer.parseInt(loggerId));
    if (! StringUtils.isEmpty(getSubstitutionSerialNumber())) {
    logger.setNewSerialNumber(getSubstitutionSerialNumber());
    }
    ....

    In the log file I have always the following entry even if getSubstitutionSerialNumber() is empty:
    UPDATE dbo.tblLogger SET newSerialNumber = ? WHERE loggerId = ?

    And this fails because of a database trigger. Maybe it's a caching problem because in the previous call the getSubstitutionSerialNumber() was not empty.

    Thanks, Lothar
    ______________________________________________________________
    Verschicken Sie romantische, coole und witzige Bilder per SMS!
    Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193



    This archive was generated by hypermail 2.0.0 : Tue Nov 15 2005 - 04:35:13 EST