Re: conditional update is executed even if condition is false

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Nov 19 2005 - 08:23:08 EST

  • Next message: Andrus Adamchik: "Re: boolean expressions"

    Can't think of any Cayenne-related reasons (it doesn't mean it is not
    Cayenne's fault of course). I guess debugging your code is the only
    way to find the answer.

    Andrus

    On Nov 15, 2005, at 12:35 PM, Lothar Krenzien wrote:
    > 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



    This archive was generated by hypermail 2.0.0 : Sat Nov 19 2005 - 08:23:14 EST