You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2021/05/09 17:47:36 UTC

[db-jdo] branch JDO-709 updated: JDO-709: Added PC class using annotations to define the converter class

This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch JDO-709
in repository https://gitbox.apache.org/repos/asf/db-jdo.git


The following commit(s) were added to refs/heads/JDO-709 by this push:
     new be853a4  JDO-709: Added PC class using annotations to define the converter class
be853a4 is described below

commit be853a48ae70fee2ecdfa9c22f3540847a87e1f7
Author: Michael Bouschen <mb...@apache.org>
AuthorDate: Sun May 9 19:47:26 2021 +0200

    JDO-709: Added PC class using annotations to define the converter class
---
 .../tck/api/converter/AttributeConverterTest.java  | 189 +++++++++++++++------
 .../java/org/apache/jdo/tck/pc/mylib/IPCRect.java  |  28 +++
 .../org/apache/jdo/tck/pc/mylib/PCRectString.java  |   7 +-
 ...CRectString.java => PCRectStringAnnotated.java} |  25 ++-
 .../org/apache/jdo/tck/pc/mylib/package.jdo        |   5 +
 .../org/apache/jdo/tck/pc/mylib/package.jdo        |   2 +
 .../apache/jdo/tck/pc/mylib/package-standard.orm   |   4 +
 .../sql/derby/applicationidentity/schema.sql       |  10 +-
 .../sql/derby/datastoreidentity/schema.sql         |  11 +-
 9 files changed, 218 insertions(+), 63 deletions(-)

diff --git a/tck/src/main/java/org/apache/jdo/tck/api/converter/AttributeConverterTest.java b/tck/src/main/java/org/apache/jdo/tck/api/converter/AttributeConverterTest.java
index 4e260e6..36f1b7b 100644
--- a/tck/src/main/java/org/apache/jdo/tck/api/converter/AttributeConverterTest.java
+++ b/tck/src/main/java/org/apache/jdo/tck/api/converter/AttributeConverterTest.java
@@ -17,7 +17,9 @@
 package org.apache.jdo.tck.api.converter;
 
 import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.IPCRect;
 import org.apache.jdo.tck.pc.mylib.PCRectString;
+import org.apache.jdo.tck.pc.mylib.PCRectStringAnnotated;
 import org.apache.jdo.tck.pc.mylib.Point;
 import org.apache.jdo.tck.util.BatchTestRunner;
 import org.apache.jdo.tck.util.PointToStringConverter;
@@ -25,6 +27,7 @@ import org.apache.jdo.tck.util.PointToStringConverter;
 import javax.jdo.JDOHelper;
 import javax.jdo.Query;
 import javax.jdo.Transaction;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 
 /**
@@ -35,7 +38,7 @@ import java.util.List;
  *<B>Assertion ID:</B> [not identified]
  *<BR>
  *<B>Assertion Description: </B>
- * A PCRectString instance refers two Point instances, that are stored as strings in the datastore.
+ * A IPCRect instance refers two Point instances, that are stored as strings in the datastore.
  * A Point instance is converted using an AttributeConverter.
  */
 public class AttributeConverterTest extends JDO_Test {
@@ -60,19 +63,92 @@ public class AttributeConverterTest extends JDO_Test {
     @Override
     protected void localSetUp() {
         addTearDownClass(PCRectString.class);
+        addTearDownClass(PCRectStringAnnotated.class);
     }
 
     /**
-     * Test method creating a PCRectString instance.
-     * It should call AttributeConverter method convertToDatastore.
+     * Test method creating and storing a PCRectString instance.
      */
     public void testStorePCRectStringInstance() {
+        runStoreIPCRectInstance(PCRectString.class);
+    }
+
+    /**
+     * Test method reading a PCRectString instance from the datastore.
+     */
+    public void testReadPCRectStringInstance() {
+        runReadIPCRectInstance(PCRectString.class);
+    }
+
+    /**
+     * Test method modifying a PCRectString instance and storing in the datastore.
+     */
+    public void testModifyPCRectStringInstance() {
+        runModifyIPCRectInstance(PCRectString.class);
+    }
+
+    /**
+     * Test method running a PCRectString query with a query parameter of type Point.
+     */
+    public void testPCRectStringQueryWithPointParam() throws Exception {
+        runQueryWithPointParameter(PCRectString.class);
+    }
+
+    /**
+     * Test method running a PCRectString query with a query parameter of type String.
+     */
+    public void testPCRectStringQueryWithStringParam() throws Exception {
+        runQueryWithStringParameter(PCRectString.class);
+    }
+
+    /**
+     * Test method creating and storing a PCRectStringAnnotated instance.
+     */
+    public void testStorePCRectStringAnnotatedInstance() {
+        runStoreIPCRectInstance(PCRectStringAnnotated.class);
+    }
+
+    /**
+     * Test method reading a PCRectStringAnnotated instance from the datastore.
+     */
+    public void testReadPCRectStringAnnotatedInstance() {
+        runReadIPCRectInstance(PCRectStringAnnotated.class);
+    }
+
+    /**
+     * Test method modifying a PCRectStringAnnotated instance and storing in the datastore.
+     */
+    public void testModifyPCRectStringAnnotatedInstance() {
+        runModifyIPCRectInstance(PCRectStringAnnotated.class);
+    }
+
+    /**
+     * Test method running a PCRectStringAnnotated query with a query parameter of type String.
+     */
+    public void testPCRectStringAnnotatedQueryWithPointParam() throws Exception {
+        runQueryWithPointParameter(PCRectStringAnnotated.class);
+    }
+
+    /**
+     * Test method running a PCRectStringAnnotated query with a query parameter of type Point.
+     */
+    public void testPCRectStringAnnotatedQueryWithStringParam() throws Exception {
+        runQueryWithStringParameter(PCRectStringAnnotated.class);
+    }
+
+    // Helper methods
+
+    /**
+     * Helper method creating a IPCRect instance.
+     * It should call AttributeConverter method convertToDatastore.
+     */
+    private <T extends IPCRect> void runStoreIPCRectInstance(Class<T> pcrectClass) {
         int nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls();
         int nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls();
 
-        // Create a persistent PCRectString instance and store its oid
+        // Create a persistent IPCRect instance and store its oid
         // AttributeConverter method convertToDatastore is called when persisting instance
-        createPCRectStringInstances(1);
+        createIPCRectInstances(pcrectClass, 1);
 
         // convertToDatastore should be called twice
         assertEquals(2, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls);
@@ -81,20 +157,20 @@ public class AttributeConverterTest extends JDO_Test {
     }
 
     /**
-     * Test method reading a PCRectString instance from the datastore.
+     * Helper method reading a IPCRect instance from the datastore.
      * It should call AttributeConverter method convertToAttribute.
      */
-    public void testReadPCRectStringInstance() {
-        PCRectString rect;
+    private <T extends IPCRect> void runReadIPCRectInstance(Class<T> pcrectClass) {
+        IPCRect rect;
         Object oid;
         int nrOfDbCalls;
         int nrOfAttrCalls;
 
-        // Create a persistent PCRectString instance and store its oid
-        oid = createPCRectStringInstances(1);
+        // Create a persistent IPCRect instance and store its oid
+        oid = createIPCRectInstances(pcrectClass, 1);
 
         // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached
-        pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, PCRectString.class);
+        pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass);
         pm.close();
         pm = null;
 
@@ -102,8 +178,8 @@ public class AttributeConverterTest extends JDO_Test {
         nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls();
         pm = getPM();
         pm.currentTransaction().begin();
-        // Read the PCRectString instance from the datastore, this should call convertToAttribute
-        rect = (PCRectString)pm.getObjectById(oid);
+        // Read the IPCRect instance from the datastore, this should call convertToAttribute
+        rect = (IPCRect)pm.getObjectById(oid);
         Point ul = rect.getUpperLeft();
         Point lr = rect.getLowerRight();
         pm.currentTransaction().commit();
@@ -120,29 +196,29 @@ public class AttributeConverterTest extends JDO_Test {
     }
 
     /**
-     * Test method modifying a PCRectString instance.
+     * Helper method modifying a IPCRect instance.
      * It should call AttributeConverter method convertToDatastore.
      */
-    public void testModifyPCRectStringInstance() {
+    private <T extends IPCRect> void runModifyIPCRectInstance(Class<T> pcrectClass) {
         Transaction tx;
-        PCRectString rect;
+        IPCRect rect;
         Object oid;
         int nrOfDbCalls;
         int nrOfAttrCalls;
 
-        // Create a persistent PCRectString instance and store its oid
-        oid = createPCRectStringInstances(1);
+        // Create a persistent IPCRect instance and store its oid
+        oid = createIPCRectInstances(pcrectClass, 1);
 
         nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls();
         nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls();
         pm = getPM();
         tx = pm.currentTransaction();
         tx.begin();
-        rect = (PCRectString)pm.getObjectById(oid);
-        // Update PCRectString instance, this should call convertToDatastore
+        rect = (IPCRect)pm.getObjectById(oid);
+        // Update IPCRect instance, this should call convertToDatastore
         rect.setUpperLeft(new Point(UL_X + 1, UL_Y + 1));
         rect.setLowerRight(new Point(LR_X + 1, LR_Y + 1));
-        // PCRectString instance should be dirty
+        // IPCRect instance should be dirty
         assertTrue(JDOHelper.isDirty(rect));
         tx.commit();
 
@@ -153,24 +229,24 @@ public class AttributeConverterTest extends JDO_Test {
     }
 
     /**
-     * Test method running a query with a Point parameter.
+     * Helper method running a query with a Point parameter.
      * The parameter value is converted using the AttributeConverter.
      * @throws Exception
      */
-    public void testQueryWithPointParameter() throws Exception {
+    private <T extends IPCRect> void runQueryWithPointParameter(Class<T> pcrectClass) throws Exception {
         int nrOfDbCalls;
         int nrOfAttrCalls;
 
         nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls();
         nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls();
-        createPCRectStringInstances(5);
+        createIPCRectInstances(pcrectClass, 5);
         // convertToDatastore should be called twice per instance = 10 times
         assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls);
         // convertToAttribute should not be called
         assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls);
 
         // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached
-        pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, PCRectString.class);
+        pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass);
         pm.close();
         pm = null;
 
@@ -178,12 +254,12 @@ public class AttributeConverterTest extends JDO_Test {
         nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls();
         pm = getPM();
         pm.currentTransaction().begin();
-        try (Query<PCRectString> q = pm.newQuery(PCRectString.class, "this.upperLeft == :point")) {
+        try (Query<T> q = pm.newQuery(pcrectClass, "this.upperLeft == :point")) {
             q.setParameters(new Point(UL_X + 1, UL_Y + 1));
             // AttributeConverter method convertToAttribute is called when loading instance from the datastore
-            List<PCRectString> res = q.executeList();
+            List<T> res = q.executeList();
             assertEquals(1, res.size());
-            PCRectString rect = res.get(0);
+            IPCRect rect = res.get(0);
             Point ul = rect.getUpperLeft();
             Point lr = rect.getLowerRight();
 
@@ -192,6 +268,8 @@ public class AttributeConverterTest extends JDO_Test {
             assertEquals(UL_Y+1, ul.getY() == null ? 0 : ul.getY().intValue());
             assertEquals(LR_X+1, lr.getX());
             assertEquals(LR_Y+1, lr.getY() == null ? 0 : lr.getY().intValue());
+        } catch (Exception e) {
+            fail(e.getMessage());
         } finally {
             pm.currentTransaction().commit();
         }
@@ -203,24 +281,24 @@ public class AttributeConverterTest extends JDO_Test {
     }
 
     /**
-     * Test method running a query with a Point parameter.
+     * Helper method running a query with a Point parameter.
      * The string parameter is compared to the converted Point field.
      * @throws Exception
      */
-    public void testQueryWithStringParameter() throws Exception {
+    private <T extends IPCRect> void runQueryWithStringParameter(Class<T> pcrectClass) throws Exception {
         int nrOfDbCalls;
         int nrOfAttrCalls;
 
         nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls();
         nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls();
-        createPCRectStringInstances(5);
+        createIPCRectInstances(pcrectClass,5);
         // convertToDatastore should be called twice per instance = 10 times
         assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls);
         // convertToAttribute should not be called
         assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls);
 
         // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached
-        pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, PCRectString.class);
+        pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass);
         pm.close();
         pm = null;
 
@@ -228,13 +306,13 @@ public class AttributeConverterTest extends JDO_Test {
         nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls();
         pm = getPM();
         pm.currentTransaction().begin();
-        try (Query<PCRectString> q = pm.newQuery(PCRectString.class, "this.upperLeft == str")) {
+        try (Query<T> q = pm.newQuery(pcrectClass, "this.upperLeft == str")) {
             q.declareParameters("String str");
             q.setParameters("3:12");
             // AttributeConverter method convertToAttribute is called when loading instance from the datastore
-            List<PCRectString> res = q.executeList();
+            List<T> res = q.executeList();
             assertEquals(1, res.size());
-            PCRectString rect = res.get(0);
+            IPCRect rect = res.get(0);
             Point ul = rect.getUpperLeft();
             Point lr = rect.getLowerRight();
 
@@ -255,27 +333,42 @@ public class AttributeConverterTest extends JDO_Test {
     }
 
     /**
-     * Helper method to create PCRectString instances.
-     * @param nrOfObjects number of PCRectString instances to be created
-     * @return ObjectId of the first PCRectString instance
+     * Helper method to create IPCRect instances.
+     * @param pcrectClass class instance of the IPCRect implementation class to be craeted
+     * @param nrOfObjects number of IPCRect instances to be created
+     * @return ObjectId of the first IPCRect instance
      */
-    private Object createPCRectStringInstances(int nrOfObjects) {
-        PCRectString rect;
-        Object oid;
+    private <T extends IPCRect> Object createIPCRectInstances(Class<T> pcrectClass, int nrOfObjects) {
+        IPCRect rect;
+        Object oid = null;
 
         if (nrOfObjects < 1) {
             return null;
         }
 
         pm = getPM();
-        pm.currentTransaction().begin();
-        rect = new PCRectString(new Point(UL_X, UL_Y), new Point(LR_X, LR_Y));
-        pm.makePersistent(rect);
-        oid = pm.getObjectId(rect);
-        for (int i = 1; i < nrOfObjects; i++) {
-            pm.makePersistent(new PCRectString(new Point(UL_X + i, UL_Y + i), new Point(LR_X + i, LR_Y + i)));
+        try {
+            pm.currentTransaction().begin();
+            rect = pcrectClass.getConstructor().newInstance();
+            rect.setUpperLeft(new Point(UL_X, UL_Y));
+            rect.setLowerRight(new Point(LR_X, LR_Y));
+            pm.makePersistent(rect);
+            oid = pm.getObjectId(rect);
+            for (int i = 1; i < nrOfObjects; i++) {
+                rect = pcrectClass.getConstructor().newInstance();
+                rect.setUpperLeft(new Point(UL_X + i, UL_Y + i));
+                rect.setLowerRight(new Point(LR_X + i, LR_Y + i));
+                pm.makePersistent(rect);
+            }
+            pm.currentTransaction().commit();
+        } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException |
+                IllegalArgumentException | InvocationTargetException ex) {
+            fail("Error creating IPCRect instance: " + ex.getMessage());
+        } finally {
+            if (pm.currentTransaction().isActive()) {
+                pm.currentTransaction().rollback();
+            }
         }
-        pm.currentTransaction().commit();
         return oid;
     }
 
diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/IPCRect.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/IPCRect.java
new file mode 100644
index 0000000..a328200
--- /dev/null
+++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/IPCRect.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mylib;
+
+/**
+ * Interface for common methods of implementation classes PCRectString and PCRectStringAnnotated.
+ */
+public interface IPCRect {
+    Point getUpperLeft();
+    void setUpperLeft(Point upperLeft);
+
+    Point getLowerRight();
+    void setLowerRight(Point lowerRight);
+}
diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectString.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectString.java
index 29761ce..958a9e6 100644
--- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectString.java
+++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectString.java
@@ -22,7 +22,7 @@ import java.util.Date;
  * PersistenceCapable class to test JDO AttributeConverter interface.
  * Its fields of type Point are converted to strings in the datastore.
  */
-public class PCRectString {
+public class PCRectString implements IPCRect {
     private static long counter = new Date().getTime();
 
     private static synchronized long newId() {
@@ -35,11 +35,6 @@ public class PCRectString {
 
     public PCRectString() {}
 
-    public PCRectString(Point ul, Point lr) {
-        upperLeft = ul;
-        lowerRight = lr;
-    }
-
     public Point getUpperLeft() {
         return upperLeft;
     }
diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectString.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectStringAnnotated.java
similarity index 77%
copy from tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectString.java
copy to tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectStringAnnotated.java
index 29761ce..ec177c1 100644
--- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectString.java
+++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRectStringAnnotated.java
@@ -16,29 +16,40 @@
  */
 package org.apache.jdo.tck.pc.mylib;
 
+import org.apache.jdo.tck.util.PointToStringConverter;
+
+import javax.jdo.annotations.Column;
+import javax.jdo.annotations.Convert;
+import javax.jdo.annotations.PersistenceCapable;
+import javax.jdo.annotations.Persistent;
 import java.util.Date;
 
 /**
  * PersistenceCapable class to test JDO AttributeConverter interface.
  * Its fields of type Point are converted to strings in the datastore.
  */
-public class PCRectString {
+@PersistenceCapable(table="PCRectStringAnnotated")
+public class PCRectStringAnnotated implements IPCRect {
     private static long counter = new Date().getTime();
 
     private static synchronized long newId() {
         return counter++;
     }
 
+    @Column(name="ID")
     private long id = newId();
+
+    @Persistent
+    @Column(name="UPPER_LEFT")
+    @Convert(value = PointToStringConverter.class)
     private Point upperLeft;
-    private Point lowerRight;
 
-    public PCRectString() {}
+    @Persistent
+    @Column(name="LOWER_RIGHT")
+    @Convert(value = PointToStringConverter.class)
+    private Point lowerRight;
 
-    public PCRectString(Point ul, Point lr) {
-        upperLeft = ul;
-        lowerRight = lr;
-    }
+    public PCRectStringAnnotated() {}
 
     public Point getUpperLeft() {
         return upperLeft;
diff --git a/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo b/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo
index fe64045..2330581 100644
--- a/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo
+++ b/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo
@@ -59,6 +59,11 @@
       <field name="lowerRight" converter="org.apache.jdo.tck.util.PointToStringConverter"/>
     </class>
 
+    <class name="PCRectStringAnnotated"
+           identity-type="application" objectid-class="javax.jdo.identity.LongIdentity">
+      <field name="id" primary-key="true"/>
+    </class>
+
     <class name="PrimitiveTypes" 
            identity-type="application" objectid-class="org.apache.jdo.tck.pc.mylib.PrimitiveTypes$Oid">
       <field name="id" primary-key="true"/>
diff --git a/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo b/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo
index fdf9561..f5da7db 100644
--- a/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo
+++ b/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo
@@ -43,6 +43,8 @@
       </fetch-group>
     </class>
 
+    <class name="PCRectStringAnnotated" identity-type="datastore"/>
+
     <class name="PCRectString" identity-type="datastore">
       <field name="upperLeft" converter="org.apache.jdo.tck.util.PointToStringConverter"/>
       <field name="lowerRight" converter="org.apache.jdo.tck.util.PointToStringConverter"/>
diff --git a/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-standard.orm b/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-standard.orm
index 703cb21..e7f1ac9 100644
--- a/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-standard.orm
+++ b/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-standard.orm
@@ -60,6 +60,10 @@
       <field name="upperLeft" column="UPPER_LEFT"/>
     </class>
 
+    <class name="PCRectStringAnnotated">
+      <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+    </class>
+
     <class name="PrimitiveTypes" table="PrimitiveTypes">
       <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
       <field name="id" column="ID"/>
diff --git a/tck/src/main/resources/sql/derby/applicationidentity/schema.sql b/tck/src/main/resources/sql/derby/applicationidentity/schema.sql
index b59914c..4596103 100644
--- a/tck/src/main/resources/sql/derby/applicationidentity/schema.sql
+++ b/tck/src/main/resources/sql/derby/applicationidentity/schema.sql
@@ -62,6 +62,7 @@ CREATE TABLE Item (
 
 DROP TABLE PCRect;
 DROP TABLE PCRectString;
+DROP TABLE PCRectStringAnnotated;
 DROP TABLE PCPoint;
 DROP TABLE VersionedPCPoint;
 DROP TABLE PCPoint2;
@@ -101,7 +102,14 @@ CREATE TABLE PCRectString (
     ID BIGINT NOT NULL,
     UPPER_LEFT VARCHAR(30),
     LOWER_RIGHT VARCHAR(30),
-    CONSTRAINT PCRCT2_CONST PRIMARY KEY (ID)
+    CONSTRAINT PCRCTSTR_CONST PRIMARY KEY (ID)
+);
+
+CREATE TABLE PCRectStringAnnotated (
+    ID BIGINT NOT NULL,
+    UPPER_LEFT VARCHAR(30),
+    LOWER_RIGHT VARCHAR(30),
+    CONSTRAINT PCRCTANN_CONST PRIMARY KEY (ID)
 );
 
 CREATE TABLE PrimitiveTypes (
diff --git a/tck/src/main/resources/sql/derby/datastoreidentity/schema.sql b/tck/src/main/resources/sql/derby/datastoreidentity/schema.sql
index 985a126..7fc3f17 100644
--- a/tck/src/main/resources/sql/derby/datastoreidentity/schema.sql
+++ b/tck/src/main/resources/sql/derby/datastoreidentity/schema.sql
@@ -42,6 +42,7 @@ CREATE TABLE address (
 
 DROP TABLE PCRect;
 DROP TABLE PCRectString;
+DROP TABLE PCRectStringAnnotated;
 DROP TABLE PCPoint;
 DROP TABLE VersionedPCPoint;
 DROP TABLE PCPoint2;
@@ -86,7 +87,15 @@ CREATE TABLE PCRectString (
     ID BIGINT,
     UPPER_LEFT VARCHAR(30),
     LOWER_RIGHT VARCHAR(30),
-    CONSTRAINT PCRCT2_CONST PRIMARY KEY (DATASTORE_IDENTITY)
+    CONSTRAINT PCRCTSTR_CONST PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+CREATE TABLE PCRectStringAnnotated (
+    DATASTORE_IDENTITY BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID BIGINT,
+    UPPER_LEFT VARCHAR(30),
+    LOWER_RIGHT VARCHAR(30),
+    CONSTRAINT PCRCTANN_CONST PRIMARY KEY (DATASTORE_IDENTITY)
 );
 
 CREATE TABLE PrimitiveTypes (