Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 63693 invoked from network); 11 Jul 2005 16:31:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jul 2005 16:31:07 -0000 Received: (qmail 38040 invoked by uid 500); 11 Jul 2005 16:31:07 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 38027 invoked by uid 99); 11 Jul 2005 16:31:06 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jul 2005 09:31:06 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [62.154.194.149] (HELO miraculix.spree.de) (62.154.194.149) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jul 2005 09:31:04 -0700 Received: from [172.16.1.19] (rio.spree.de [172.16.1.19]) by miraculix.spree.de (8.11.6/8.11.6) with ESMTP id j6BGUxQ08909 for ; Mon, 11 Jul 2005 18:30:59 +0200 Message-ID: <42D2A00A.9@spree.de> Date: Mon, 11 Jul 2005 18:36:26 +0200 From: Michael Watzek Organization: Tech@Spree GmbH User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jdo-dev@db.apache.org Subject: Re: JDOFatalInternalException using single field identity References: <42C4208F.2070101@spree.de> In-Reply-To: <42C4208F.2070101@spree.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Andy, I figured out that the exception below was thrown because I made a mistake in the orm metadata: The test case defines a superclass and a subclass. Both are persistence capable and both define define persistent fields. Mistakenly, I assigned all column/field mappings to the subclass in the orm metadata. That's why the exception is thrown. If I move the fields in the superclass to the subclass, then the test case succeeds. I still have a question: Due to the fact that the above use case indicates an user error, should JPOX throw a JDOFatalUserException instead of a JDOFatalInternalException? Regards, Michael > Hi Erik, Andy, > > I have written a test case checking single field identity. For this > purpose, I created new PC classes, new jdo files, new orm files, and I > extended the schema for application identity. When I run the test case, > I get a JDOFatalInternalException from JPOX (see below). Currently, I > run build jpox-20050617.022105.jar. > > The exception is thrown when a PC instance is made persistent. I cannot > find an error in the meta data. So, please have a look at the attached > files. I attached the Java file of the PC class and the meta data files. > Is there anything wrong? > > Regards, > Michael > > testSingleFieldIdentityNotIntializedByte(org.apache.jdo.tck.api.persistencecapable.NewObjectIdInstance)javax.jdo.JDOFatalInternalException: > Cannot populate the field "id" of class > "org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldPrimitivebyte" > since it is already populated. > at org.jpox.metadata.FieldMetaData.mergeORMData(FieldMetaData.java:451) > at org.jpox.metadata.ClassMetaData.mergeORMData(ClassMetaData.java:335) > at > org.jpox.metadata.MetaDataManager.addORMDataToClass(MetaDataManager.java:648) > > at org.jpox.metadata.ClassMetaData.populate(ClassMetaData.java:395) > at > org.jpox.metadata.MetaDataManager.initialiseMetaDataForClass(MetaDataManager.java:948) > > at > org.jpox.metadata.MetaDataManager.getParsedMetaDataForClass(MetaDataManager.java:423) > > at > org.jpox.metadata.MetaDataManager.getMetaDataForClassOrInterface(MetaDataManager.java:327) > > at > org.jpox.metadata.MetaDataManager.getMetaDataForClass(MetaDataManager.java:285) > > at org.jpox.state.StateManagerImpl.(StateManagerImpl.java:558) > at > org.jpox.AbstractPersistenceManager.internalMakePersistent(AbstractPersistenceManager.java:973) > > at > org.jpox.AbstractPersistenceManager.makePersistent(AbstractPersistenceManager.java:1010) > > at > org.apache.jdo.tck.api.persistencecapable.PersistenceCapableTest.createPersistentInstances(PersistenceCapableTest.java:90) > > at > org.apache.jdo.tck.api.persistencecapable.PersistenceCapableTest.localSetUp(PersistenceCapableTest.java:43) > > at org.apache.jdo.tck.JDO_Test.setUp(JDO_Test.java:178) > at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:194) > at > org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128) > at > org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106) > > > ------------------------------------------------------------------------ > > /* > * Copyright 2005 The Apache Software Foundation. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > > package org.apache.jdo.tck.pc.singlefieldidentity; > > import javax.jdo.identity.ByteIdentity; > import javax.jdo.identity.SingleFieldIdentity; > > /** > * The PC class for testing ByteIdentity. > * @author Michael Watzek > */ > public class PCPointSingleFieldPrimitivebyte extends PCPointSingleField { > > /** > * Returns a unique value, used for primary key field initialization. > * @return a unique value > */ > private static byte newId() { > synchronized (PCPointSingleFieldPrimitivebyte.class) { > return (byte) ((counter++) % Byte.MAX_VALUE); > } > } > > /** > * The primary key field. > */ > private byte id = newId(); > > /** > * This constructor is used by test cases checking assertion A7.12-39:
> * The instance returned is initialized with the value of the primary key > * field of the instance on which the method is called. > * @param x > * @param y > */ > public PCPointSingleFieldPrimitivebyte(int x, int y) { > super(x, y); > } > > /** > * Returns true if the given the key of the given > * SingleFieldIdentity instance equals the key in the subclass > * of this class. > * @param singleFieldIdentity the single field identity to check. > * @return returns true if the given the key of the given > * SingleFieldIdentity instance equals the key in the subclass > * of this class. > */ > public boolean equals(SingleFieldIdentity singleFieldIdentity) { > return this.id==((ByteIdentity)singleFieldIdentity).getKey(); > } > > public String toString() { > return super.toString() + this.id; > } > } > > > ------------------------------------------------------------------------ > > /* > * Copyright 2005 The Apache Software Foundation. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > > package org.apache.jdo.tck.pc.singlefieldidentity; > > import java.io.Serializable; > import java.util.Date; > > import javax.jdo.identity.SingleFieldIdentity; > > /** > * This is the super class for all PCPoint single indentity classes. > * It defines an abstract method equals(SingleFieldIdentity). > * That method ensures that all single identity test cases have a common > * implementation. > * @author Michael Watzek > */ > abstract public class PCPointSingleField implements Serializable { > > /** > * This field is used by subclasses > * to compute the value of the primary key field. > */ > static long counter = new Date().getTime(); > > public int x; > public Integer y; > > /** > * This constructor is used by test cases checking assertion A7.12-38:
> * For classes using single field identity method > * PersistenceCapable.newObjectIdInstance() must be called > * on a persistent instance with its primary key field initialized, > * or a JDOFatalInternalException is thrown. > */ > public PCPointSingleField() { > } > > /** > * This constructor is used by test cases checking assertion A7.12-39:
> * The instance returned is initialized with the value of the primary key > * field of the instance on which the method is called. > * @param x > * @param y > */ > public PCPointSingleField(int x, int y) { > this.x = x; > this.y = new Integer(y); > } > > /** > * Returns true if the given the key of the given > * SingleFieldIdentity instance equals the key in the subclass > * of this class. > * @param singleFieldIdentity the single field identity to check. > * @return returns true if the given the key of the given > * SingleFieldIdentity instance equals the key in the subclass > * of this class. > */ > abstract public boolean equals(SingleFieldIdentity singleFieldIdentity); > > public String toString() { > return '(' + getClass().getName() + ')'; > } > > public void setX(int x) { > this.x = x; > } > > public int getX() { > return x; > } > > public void setY(Integer y) { > this.y = y; > } > > public Integer getY() { > return y; > } > > public String name() { > return " x: " + getX() + ", y: " + getY().intValue(); > } > } > > > ------------------------------------------------------------------------ > > > > > > > > identity-type="application" objectid-class="javax.jdo.identity.ByteIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.ByteIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.CharIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.CharIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.IntIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.IntIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.LongIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.LongIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.ShortIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.ShortIdentity"> > > > > identity-type="application" objectid-class="javax.jdo.identity.StringIdentity"> > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- ------------------------------------------------------------------- Michael Watzek Tech@Spree Engineering GmbH mailto:mwa.tech@spree.de Buelowstr. 66 Tel.: ++49/30/235 520 36 10783 Berlin - Germany Fax.: ++49/30/217 520 12 http://www.spree.de/ -------------------------------------------------------------------