Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 63209 invoked from network); 21 Nov 2007 17:26:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2007 17:26:16 -0000 Received: (qmail 41172 invoked by uid 500); 21 Nov 2007 17:26:04 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 41137 invoked by uid 500); 21 Nov 2007 17:26:03 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 41128 invoked by uid 99); 21 Nov 2007 17:26:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Nov 2007 09:26:03 -0800 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [192.18.43.132] (HELO sca-es-mail-1.sun.com) (192.18.43.132) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Nov 2007 17:25:51 +0000 Received: from fe-sfbay-10.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id lALHPgBI025418 for ; Wed, 21 Nov 2007 09:25:44 -0800 (PST) Received: from conversion-daemon.fe-sfbay-10.sun.com by fe-sfbay-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JRV00G019PK8400@fe-sfbay-10.sun.com> (original mail from Craig.Russell@Sun.COM) for dev@openjpa.apache.org; Wed, 21 Nov 2007 09:25:42 -0800 (PST) Received: from [10.0.241.238] ([192.18.41.196]) by fe-sfbay-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0JRV005PT9QU0200@fe-sfbay-10.sun.com> for dev@openjpa.apache.org; Wed, 21 Nov 2007 09:25:42 -0800 (PST) Date: Wed, 21 Nov 2007 09:25:38 -0800 From: Craig L Russell Subject: Fwd: [jira] Commented: (OPENJPA-446) Problem when setting String fields of detached objects Sender: Craig.Russell@Sun.COM To: dev@openjpa.apache.org Message-id: MIME-version: 1.0 X-Mailer: Apple Mail (2.752.3) Content-type: multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-133-462890543; micalg=sha1 References: <7465812.1195587283008.JavaMail.jira@brutus> X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-133-462890543 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed First, thanks for the patch and all the work on debugging. A couple of comments on the JIRA stuff... 1. If a patch is submitted without granting license to Apache, then =20 it needs to be resubmitted (as was done here) with the license grant. 2. A patch can be resubmitted under the same name, and JIRA figures =20 out that only the latest is to be used. The other one is grayed out =20 so you have to think twice about downloading it. 3. The submitter of a patch can remove the patch. I can't verify this =20= but the original submitter should be able to. If there is a problem, =20 we can fix JIRA to allow it. Craig Begin forwarded message: > From: "Patrick Linskey (JIRA)" > Date: November 20, 2007 11:34:43 AM PST > To: dev@openjpa.apache.org > Subject: [jira] Commented: (OPENJPA-446) Problem when setting =20 > String fields of detached objects > Reply-To: dev@openjpa.apache.org > > > [ https://issues.apache.org/jira/browse/OPENJPA-446?=20 > page=3Dcom.atlassian.jira.plugin.system.issuetabpanels:comment-=20 > tabpanel#action_12544020 ] > > Patrick Linskey commented on OPENJPA-446: > ----------------------------------------- > > Thanks for the debugging work on this. > > Is it ok for us to put the DetachAttachTest.zip test files into =20 > OpenJPA under the ASL license? > >> Problem when setting String fields of detached objects >> ------------------------------------------------------ >> >> Key: OPENJPA-446 >> URL: https://issues.apache.org/jira/browse/=20 >> OPENJPA-446 >> Project: OpenJPA >> Issue Type: Bug >> Components: jpa, kernel >> Affects Versions: 1.0.1 >> Environment: OpenJPA 1.0.1 >> Java 1.5.0_13 >> MySQL Server 5.0 >> MySQL Connector Java 5.0.6 >> Reporter: Jonas Petersen >> Fix For: 1.0.2, 1.1.0 >> >> Attachments: detach-attach-fix-proper.patch, detach-attach-=20= >> fix.patch, DetachAttachTest.zip >> >> >> I would like to report some strange behavior with detach and =20 >> merge. To me it looks like a bug. >> I'm trying implement the following strategy: >> >> persistence context A: >> 1. get persistent object >> 2. detach the object >> no persistence context: >> 3. modify the (detached) object >> persistence context B: >> 4. attach (merge) the object >> This is quite simple and straight forward. It generally works =20 >> except in one situation. When committing the merge() (step 4) an =20 >> "optimistic locking error" is is thrown under the following =20 >> condition: (step 3) a (String) field is set to the same text that =20 >> it already contains but using a different String instance. In =20 >> other words, when the following expressions are true: >> >> newString.equals(oldString) >> newString !=3D oldString >> I have written some test code that reproduces this effect (see =20 >> Attachment). >> The tests are using the same code except for one line: >> Test 1 sets the String to a different one than the object contains: >> record.setContent("a text different than the one in the record"); >> Test 2 sets the String to the same instance the object contains: >> record.setContent(record.getContent()); >> Test 3 sets the String to the same text but as a different String =20 >> instance: >> record.setContent(record.getContent()+""); >> This is the result (output of the test run): >> ---------------------------------- >> Test 1: SUCCESS >> Test 2: SUCCESS >> Test 3: FAILED (Optimistic locking errors were detected when flushing >> to the data store. The following objects may have =20 >> been >> concurrently modified in another transaction: >> [test.Record-1]) >> ---------------------------------- >> While doing some debugging I noticed two things: >> 1. When setting the value: >> Class: org.apache.openjpa.kernel.DetachedStateManager >> Line: 555 >> Method: settingStringField() >> if (cur =3D=3D next || !_loaded.get(idx)) >> return; >> Here the old and the new value (String) is compared with the =3D=3D =20= >> operator. >> The expression can be false with the same text (but different =20 >> instances). I find this interesting as it matches exacly the =20 >> problematic condition. I think an .equals() would fix the issue I =20 >> am having. But I suppose there is something going wrong at another =20= >> place as well. >> 2. Here is the point where execution splits into different ways =20 >> when calling commit(). >> Class: org.apache.openjpa.jdbc.kernel.AbstractUpdateManager >> Line: 151 >> Method: populateRowManager() >> } else if ((dirty =3D ImplHelper.getUpdateFields(sm)) !=3D null) = { >> In the tests that succeed "ImplHelper.getUpdateFields(sm)" will =20 >> return a BitSet. So the condition is true. >> In the tests that fail "ImplHelper.getUpdateFields(sm)" will =20 >> return null. So the condition is false. >> Note: the problem persist with OpenJPA 1.1.0-SNAPSHOT. When run =20 >> without enhancing the Record class, all tests will succeed though =20 >> (printing this message =84INFO [main] openjpa.Enhance - Creating =20= >> subclass for "[class test.Record]". This means that your =20 >> application will be less efficient and will consume more memory =20 >> than it would if you ran the OpenJPA enhancer. Additionally, lazy =20 >> loading will not be available for one-to-one and many-to-one =20 >> persistent attributes in types using field access; they will be =20 >> loaded eagerly instead.") >> Regards >> Jonas > > --=20 > This message is automatically generated by JIRA. > - > You can reply to this email to add a comment to the issue online. > Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp! --Apple-Mail-133-462890543 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGUDCCAwkw ggJyoAMCAQICECpJVMO68ii+Xfsc1O1YYFIwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA2MTIwOTE5NTEwNVoXDTA3MTIwOTE5NTEw NVowbDEQMA4GA1UEBBMHUnVzc2VsbDEUMBIGA1UEKhMLQ3JhaWcgTGFpcmQxHDAaBgNVBAMTE0Ny YWlnIExhaXJkIFJ1c3NlbGwxJDAiBgkqhkiG9w0BCQEWFUNyYWlnLlJ1c3NlbGxAU3VuLkNPTTCC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