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.<init>(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 <code>ByteIdentity</code>.
* @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:<br>
* 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 <code>true</code> if the given the key of the given
* <code>SingleFieldIdentity</code> instance equals the key in the subclass
* of this class.
* @param singleFieldIdentity the single field identity to check.
* @return returns <code>true</code> if the given the key of the given
* <code>SingleFieldIdentity</code> 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 <code>equals(SingleFieldIdentity)</code>.
* 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:<br>
* For classes using single field identity method
* <code>PersistenceCapable.newObjectIdInstance()</code> 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:<br>
* 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 <code>true</code> if the given the key of the given
* <code>SingleFieldIdentity</code> instance equals the key in the subclass
* of this class.
* @param singleFieldIdentity the single field identity to check.
* @return returns <code>true</code> if the given the key of the given
* <code>SingleFieldIdentity</code> 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();
}
}
------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN"
"http://java.sun.com/dtd/jdo_2_0.dtd">
<jdo>
<package name="org.apache.jdo.tck.pc.singlefieldidentity">
<class name="PCPointSingleFieldPrimitivebyte"
identity-type="application"
objectid-class="javax.jdo.identity.ByteIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldByte"
identity-type="application"
objectid-class="javax.jdo.identity.ByteIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldPrimitivechar"
identity-type="application"
objectid-class="javax.jdo.identity.CharIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldCharacter"
identity-type="application"
objectid-class="javax.jdo.identity.CharIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldPrimitiveint"
identity-type="application"
objectid-class="javax.jdo.identity.IntIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldInteger"
identity-type="application"
objectid-class="javax.jdo.identity.IntIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldPrimitivelong"
identity-type="application"
objectid-class="javax.jdo.identity.LongIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldLong"
identity-type="application"
objectid-class="javax.jdo.identity.LongIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldPrimitiveshort"
identity-type="application"
objectid-class="javax.jdo.identity.ShortIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldShort"
identity-type="application"
objectid-class="javax.jdo.identity.ShortIdentity">
<field name="id" primary-key="true"/>
</class>
<class name="PCPointSingleFieldString"
identity-type="application"
objectid-class="javax.jdo.identity.StringIdentity">
<field name="id" primary-key="true"/>
</class>
</package>
</jdo>
------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE orm PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata
2.0//EN" "http://java.sun.com/dtd/orm_2_0.dtd">
<orm>
<package name="org.apache.jdo.tck.pc.singlefieldidentity">
<class name="PCPointSingleFieldPrimitivebyte"
table="PCPointSingleFieldPrimitivebyte">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldByte" table="PCPointSingleFieldByte">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldPrimitivechar"
table="PCPointSingleFieldPrimitivechar">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldCharacter"
table="PCPointSingleFieldCharacter">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldPrimitiveint"
table="PCPointSingleFieldPrimitiveint">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldInteger" table="PCPointSingleFieldInteger">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldPrimitivelong"
table="PCPointSingleFieldPrimitivelong">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldLong" table="PCPointSingleFieldLong">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldPrimitiveshort"
table="PCPointSingleFieldPrimitiveshort">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldShort" table="PCPointSingleFieldShort">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
<class name="PCPointSingleFieldString" table="PCPointSingleFieldString">
<field name="id" column="ID" primary-key="true"/>
<field name="x" column="X"/>
<field name="y" column="Y"/>
</class>
</package>
</orm>