Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 19204 invoked from network); 15 Mar 2010 10:14:37 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 15 Mar 2010 10:14:37 -0000 Received: (qmail 70045 invoked by uid 500); 15 Mar 2010 10:13:51 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 69959 invoked by uid 500); 15 Mar 2010 10:13:51 -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 69951 invoked by uid 99); 15 Mar 2010 10:13:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Mar 2010 10:13:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Mar 2010 10:13:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1EF71234C1EE for ; Mon, 15 Mar 2010 10:13:27 +0000 (UTC) Message-ID: <74359584.263311268648007124.JavaMail.jira@brutus.apache.org> Date: Mon, 15 Mar 2010 10:13:27 +0000 (UTC) From: "Krzysztof (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-1572) ApplicationIdTool generated ID classes do not cater for embedded composite IDs In-Reply-To: <553342108.263291268647887164.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-1572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Krzysztof updated OPENJPA-1572: ------------------------------- Description: Having ClassB identified by the composite identity of the classA which has a 'simple types' composite identity, i.e.: class ClassA { @Id int x; @Id int y; } class ClassB { @Id ClassA cA; @Id int b; } Generated ClassBId.fromstring with ApplicationIdTool passes only part of the string representation of ClassA id to classA string constructor as nexttoken is not aware of the composition of the ID and always extracts a single token which will result in the null exception. CLassBId { ... private void fromString(String str) { Tokenizer toke = new Tokenizer(str); str = toke.nextToken(); if ("null".equals(str)) b = null; else b = str; str = toke.nextToken(); if ("null".equals(str)) cA = null; else cA = new classA.classAId(str); } so, obviously for classB with a string representation like 0::1::2 only "1" is passed to the constructor using ClassA.toString which results in wrong initialization. I have not been using detachement/attachment and have been wondering if this inconsistency may have other impact during an object lifecycle. The solution would be to pass full remaining part of the string and return the last position for subsequent tokens extraction somehow. Not sure about priority, so setting to Major as a simple unit test would fail on toString/fromString combo. was: Having ClassB identified by the composite identity of the classA which has a 'simple types' composite identity, i.e.: class ClassA { @Id int x; @Id int y; } class ClassB { @Id ClassA cA; @Id int b; } Generated ClassBId.fromstring passes only part of the string representation of ClassA id to classA string constructor as nexttoken is not aware of the composition of the ID and always extracts a single token which will result in the null exception. CLassBId { ... private void fromString(String str) { Tokenizer toke = new Tokenizer(str); str = toke.nextToken(); if ("null".equals(str)) b = null; else b = str; str = toke.nextToken(); if ("null".equals(str)) cA = null; else cA = new classA.classAId(str); } so, obviously for classB with a string representation like 0::1::2 only "1" is passed to the constructor using ClassA.toString which results in wrong initialization. I have not been using detachement/attachment and have been wondering if this inconsistency may have other impact during an object lifecycle. The solution would be to pass full remaining part of the string and return the last position for subsequent tokens extraction somehow. > ApplicationIdTool generated ID classes do not cater for embedded composite IDs > ------------------------------------------------------------------------------ > > Key: OPENJPA-1572 > URL: https://issues.apache.org/jira/browse/OPENJPA-1572 > Project: OpenJPA > Issue Type: Bug > Components: tooling > Affects Versions: 2.0.0-beta2 > Reporter: Krzysztof > > Having ClassB identified by the composite identity of the classA which has a 'simple types' composite identity, i.e.: > class ClassA > { > @Id > int x; > @Id > int y; > } > class ClassB > { > @Id > ClassA cA; > @Id > int b; > } > Generated ClassBId.fromstring with ApplicationIdTool passes only part of the string representation of ClassA id to classA string constructor as nexttoken is not aware of the composition of the ID and always extracts a single token which will result in the null exception. > CLassBId { > ... > private void fromString(String str) { > Tokenizer toke = new Tokenizer(str); > str = toke.nextToken(); > if ("null".equals(str)) > b = null; > else > b = str; > str = toke.nextToken(); > if ("null".equals(str)) > cA = null; > else > cA = new classA.classAId(str); > } > so, obviously for classB with a string representation like 0::1::2 only "1" is passed to the constructor using ClassA.toString which results in wrong initialization. > I have not been using detachement/attachment and have been wondering if this inconsistency may have other impact during an object lifecycle. > The solution would be to pass full remaining part of the string and return the last position for subsequent tokens extraction somehow. > Not sure about priority, so setting to Major as a simple unit test would fail on toString/fromString combo. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.