Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 393081125C for ; Wed, 18 Jun 2014 13:22:17 +0000 (UTC) Received: (qmail 40728 invoked by uid 500); 18 Jun 2014 13:22:17 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 40718 invoked by uid 500); 18 Jun 2014 13:22:17 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 40707 invoked by uid 99); 18 Jun 2014 13:22:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jun 2014 13:22:16 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.85.220.170] (HELO mail-vc0-f170.google.com) (209.85.220.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jun 2014 13:22:14 +0000 Received: by mail-vc0-f170.google.com with SMTP id hy10so766423vcb.15 for ; Wed, 18 Jun 2014 06:21:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=249ws7EsD3FBw+Jo4+g5/3Zuy0lZhFJBj2V2WUU06Pk=; b=ar38lNf6u1x1eV13IC7x+YpoxO4e7NZkEdDSbWqvzqclLNQ9Wf77irr0bGQZnbtFjW yTacxjwWDO7OBWhrsXxQmP+uLnmXiG9c41ttNrPiaRTmstRJfjTKKdasOM4ET1zXhPg7 /WhuxGGZHfgKIsBHKwoghNGNJLYTdLhlI7vurhr2TgAXbaJB3+jbIUe7ROoct90iaf3j eDEQGR5/oacdMUfjtnDSSBiDQ4u+zivFwOK45Grsm/+IgArzewvBZ/WdC7z5/sPkWV1I fPXwxtUzILoMCpqtOMHEFE/tOAaC9WKYn+ignYqnoeXVddBV9hlgQcSiOIL7JWXALdtL I7mQ== X-Gm-Message-State: ALoCoQknumIbqYshwQUV89e1ZeKwAFfPf0YR8vR4Sx4lwviykDiCY+ZYNnOByyXnjR/c0jy0eR2h X-Received: by 10.220.159.4 with SMTP id h4mr1252472vcx.1.1403097709833; Wed, 18 Jun 2014 06:21:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.181.226 with HTTP; Wed, 18 Jun 2014 06:21:29 -0700 (PDT) In-Reply-To: References: <82FB68B3-1D49-449F-A2A5-05CD48CF6B16@objectstyle.org> From: Michael Gentry Date: Wed, 18 Jun 2014 09:21:29 -0400 Message-ID: Subject: Re: SQL UPDATE fires on non-primitive values To: Cayenne Users Content-Type: multipart/alternative; boundary=001a11c2ca0c9488c904fc1c24c6 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2ca0c9488c904fc1c24c6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Mark, We've encountered the scale issue before. Our application uses Tapestry 5 for the front-end and Cayenne for the back-end. We use a custom T5 Translator to convert all BigDecimal inputs on form submission to have a scale of 3 in our application. (T5 will use the custom translator to convert String->BigDecimal before calling the the Cayenne setter.) I don't know if you can do something similar with your environment. Also, I have a CayenneUtils class with an isDirty() method that does a deep introspection of the modified/dirty Cayenne objects ignoring phantom changes if that could be useful for you. mrg On Wed, Jun 18, 2014 at 8:56 AM, Mark Stobbe wrote= : > Thank you for the link to the code that does the check. > > I figured out that if two BigDecimal do not have the same scale, they are > considered different. I guess that makes sense. > > When I retrieve BigDecimals from Cayenne it will have the correct scale > set, but it does not set the scale of the new value before it compares. > Is this something that Cayenne can solve? > > Mark > > > > On Wed, Jun 18, 2014 at 8:29 AM, Andrus Adamchik > wrote: > > > Actually even if an object is marked as dirty after =E2=80=98setXyz=E2= =80=99, later on > > during commit Cayenne should do a proper comparison and avoid =E2=80=9C= phantom=E2=80=9D > > commits. The relevant code is in > > org.apache.cayenne.access.ObjectDiff.isNoop: > > > > > > > https://github.com/apache/cayenne/blob/master/cayenne-server/src/main/jav= a/org/apache/cayenne/access/ObjectDiff.java > > > > Andrus > > > > > > On Jun 18, 2014, at 12:03 AM, Mark Stobbe > wrote: > > > > > Hi, > > > > > > I have a decimal column which is translated to a BigDecimal. When the > > value > > > is equal to 0 and I set the value equal to 0 again, it will actually > > > perform a SQL UPDATE. The two objects are "=3D=3D", but they are "equ= als". > > > In the source I found in de PersistentObjectHolder.setValue the > > following: > > > > > > Object oldValue =3D setValueDirectly(value); > > > if (oldValue !=3D value && relationshipOwner.getObjectContext() !=3D = null) > { > > > > relationshipOwner.getObjectContext().propertyChanged(relationshipOwner, > > > relationshipName, oldValue, value); > > > .. > > > } > > > > > > Is this piece of code used for non-primitive properties? > > > > > > Mark > > > > > > PS: I am using 3.2M1 > > > > > --001a11c2ca0c9488c904fc1c24c6--