cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r463545 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/ test/java/org/apache/cayenne/ test/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/unit/jira/
Date Fri, 13 Oct 2006 01:42:23 GMT
Author: aadamchik
Date: Thu Oct 12 18:42:22 2006
New Revision: 463545

URL: http://svn.apache.org/viewvc?view=rev&rev=463545
Log:
CAY-689: DataObjectUtils must return "Object" instead of "DataObject" from all pk lookup methods
(finished)

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObjectUtils.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectUtilsTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/unit/jira/CAY_207Tst.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObjectUtils.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObjectUtils.java?view=diff&rev=463545&r1=463544&r2=463545
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObjectUtils.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObjectUtils.java
Thu Oct 12 18:42:22 2006
@@ -46,9 +46,9 @@
 public final class DataObjectUtils {
 
     /**
-     * Returns an int primary key value for a DataObject. Only works for single column
-     * numeric primary keys. If a DataObjects is transient or has an ObjectId that can not
-     * be converted to an int PK, an exception is thrown.
+     * Returns an int primary key value for a persistent object. Only works for single
+     * column numeric primary keys. If an object is transient or has an ObjectId that can
+     * not be converted to an int PK, an exception is thrown.
      */
     public static int intPKForObject(Persistent dataObject) {
         Object value = pkForObject(dataObject);
@@ -62,8 +62,8 @@
     }
 
     /**
-     * Returns a primary key value for a DataObject. Only works for single column primary
-     * keys. If a DataObjects is transient or has a compound ObjectId, an exception is
+     * Returns a primary key value for a persistent object. Only works for single column
+     * primary keys. If an object is transient or has a compound ObjectId, an exception is
      * thrown.
      */
     public static Object pkForObject(Persistent dataObject) {
@@ -81,9 +81,9 @@
     }
 
     /**
-     * Returns a primary key map for a DataObject. This method is the most generic out of
-     * all methods for primary key retrieval. It will work for all possible types of
-     * primary keys. If a DataObjects is transient, an exception is thrown.
+     * Returns a primary key map for a persistent object. This method is the most generic
+     * out of all methods for primary key retrieval. It will work for all possible types
+     * of primary keys. If an object is transient, an exception is thrown.
      */
     public static Map compoundPKForObject(Persistent dataObject) {
         return Collections.unmodifiableMap(extractObjectId(dataObject));
@@ -124,10 +124,7 @@
      * 
      * @see #objectForPK(ObjectContext, ObjectId)
      */
-    public static DataObject objectForPK(
-            ObjectContext context,
-            Class dataObjectClass,
-            int pk) {
+    public static Object objectForPK(ObjectContext context, Class dataObjectClass, int pk)
{
         return objectForPK(context, buildId(context, dataObjectClass, new Integer(pk)));
     }
 
@@ -141,7 +138,7 @@
      * 
      * @see #objectForPK(ObjectContext, ObjectId)
      */
-    public static DataObject objectForPK(
+    public static Object objectForPK(
             ObjectContext context,
             Class dataObjectClass,
             Object pk) {
@@ -159,10 +156,7 @@
      * 
      * @see #objectForPK(ObjectContext, ObjectId)
      */
-    public static DataObject objectForPK(
-            ObjectContext context,
-            Class dataObjectClass,
-            Map pk) {
+    public static Object objectForPK(ObjectContext context, Class dataObjectClass, Map pk)
{
 
         ObjEntity entity = context.getEntityResolver().lookupObjEntity(dataObjectClass);
         if (entity == null) {
@@ -183,10 +177,7 @@
      * 
      * @see #objectForPK(ObjectContext, ObjectId)
      */
-    public static DataObject objectForPK(
-            ObjectContext context,
-            String objEntityName,
-            int pk) {
+    public static Object objectForPK(ObjectContext context, String objEntityName, int pk)
{
         return objectForPK(context, buildId(context, objEntityName, new Integer(pk)));
     }
 
@@ -200,7 +191,7 @@
      * 
      * @see #objectForPK(ObjectContext, ObjectId)
      */
-    public static DataObject objectForPK(
+    public static Object objectForPK(
             ObjectContext context,
             String objEntityName,
             Object pk) {
@@ -217,10 +208,7 @@
      * 
      * @see #objectForPK(ObjectContext, ObjectId)
      */
-    public static DataObject objectForPK(
-            ObjectContext context,
-            String objEntityName,
-            Map pk) {
+    public static Object objectForPK(ObjectContext context, String objEntityName, Map pk)
{
         if (objEntityName == null) {
             throw new IllegalArgumentException("Null ObjEntity name.");
         }
@@ -233,20 +221,21 @@
      * ObjectStore, it is returned without a query. Otherwise a query is built and
      * executed against the database.
      * 
-     * @return A DataObject that matched the id, null if no matching objects were found
+     * @return A persistent object that matched the id, null if no matching objects were
+     *         found
      * @throws CayenneRuntimeException if more than one object matched ObjectId.
      */
-    public static DataObject objectForPK(ObjectContext context, ObjectId id) {
-        return (DataObject) DataObjectUtils.objectForQuery(context, new ObjectIdQuery(
+    public static Object objectForPK(ObjectContext context, ObjectId id) {
+        return DataObjectUtils.objectForQuery(context, new ObjectIdQuery(
                 id,
                 false,
                 ObjectIdQuery.CACHE));
     }
 
     /**
-     * Returns a DataObject or a DataRow that is a result of a given query. If query
-     * returns more than one object, an exception is thrown. If query returns no objects,
-     * null is returned.
+     * Returns an object or a DataRow that is a result of a given query. If query returns
+     * more than one object, an exception is thrown. If query returns no objects, null is
+     * returned.
      * 
      * @since 1.2
      */

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectUtilsTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectUtilsTst.java?view=diff&rev=463545&r1=463544&r2=463545
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectUtilsTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectUtilsTst.java
Thu Oct 12 18:42:22 2006
@@ -73,7 +73,7 @@
         DataContext context = createDataContext();
 
         // use bogus non-existent PK
-        DataObject object = DataObjectUtils.objectForPK(context, Artist.class, 44001);
+        Object object = DataObjectUtils.objectForPK(context, Artist.class, 44001);
         assertNull(object);
     }
 
@@ -105,7 +105,7 @@
         createTestData("testObjectForPKInt");
         DataContext context = createDataContext();
 
-        DataObject object = DataObjectUtils.objectForPK(context, new ObjectId(
+        Object object = DataObjectUtils.objectForPK(context, new ObjectId(
                 "Artist",
                 Artist.ARTIST_ID_PK_COLUMN,
                 new Integer(33002)));
@@ -119,7 +119,7 @@
         createTestData("testObjectForPKInt");
         DataContext context = createDataContext();
 
-        DataObject object = DataObjectUtils.objectForPK(context, Artist.class, 33002);
+        Object object = DataObjectUtils.objectForPK(context, Artist.class, 33002);
 
         assertNotNull(object);
         assertTrue(object instanceof Artist);
@@ -130,7 +130,7 @@
         createTestData("testObjectForPKInt");
         DataContext context = createDataContext();
 
-        DataObject object = DataObjectUtils.objectForPK(context, "Artist", 33002);
+        Object object = DataObjectUtils.objectForPK(context, "Artist", 33002);
 
         assertNotNull(object);
         assertTrue(object instanceof Artist);
@@ -142,7 +142,7 @@
         DataContext context = createDataContext();
 
         Map pk = Collections.singletonMap(Artist.ARTIST_ID_PK_COLUMN, new Integer(33002));
-        DataObject object = DataObjectUtils.objectForPK(context, Artist.class, pk);
+        Object object = DataObjectUtils.objectForPK(context, Artist.class, pk);
 
         assertNotNull(object);
         assertTrue(object instanceof Artist);
@@ -156,7 +156,7 @@
         Map pk = new HashMap();
         pk.put(CompoundPkTestEntity.KEY1_PK_COLUMN, "PK1");
         pk.put(CompoundPkTestEntity.KEY2_PK_COLUMN, "PK2");
-        DataObject object = DataObjectUtils.objectForPK(
+        Object object = DataObjectUtils.objectForPK(
                 context,
                 CompoundPkTestEntity.class,
                 pk);

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java?view=diff&rev=463545&r1=463544&r2=463545
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java
Thu Oct 12 18:42:22 2006
@@ -28,7 +28,6 @@
 import org.apache.art.GeneratedColumnTest2;
 import org.apache.art.GeneratedColumnTestEntity;
 import org.apache.art.MeaningfulGeneratedColumnTestEntity;
-import org.apache.cayenne.DataObject;
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.unit.CayenneTestCase;
@@ -201,7 +200,7 @@
                     master, dep1, dep2
             }));
 
-            DataObject fetchedDep2 = DataObjectUtils.objectForPK(context, id2);
+            Object fetchedDep2 = DataObjectUtils.objectForPK(context, id2);
             assertNotNull(fetchedDep2);
         }
     }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/unit/jira/CAY_207Tst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/unit/jira/CAY_207Tst.java?view=diff&rev=463545&r1=463544&r2=463545
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/unit/jira/CAY_207Tst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/unit/jira/CAY_207Tst.java
Thu Oct 12 18:42:22 2006
@@ -22,7 +22,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cayenne.DataObject;
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.access.DataContext;
 import org.apache.cayenne.access.DataDomain;
@@ -56,7 +55,7 @@
 
         try {
             // M1
-            DataObject o1 = DataObjectUtils.objectForPK(context, Manager.class, 1);
+            Manager o1 = (Manager) DataObjectUtils.objectForPK(context, Manager.class, 1);
             assertTrue(o1 instanceof CAY_207Manager1);
 
             Object p1 = o1.readProperty("clientContactType");
@@ -78,7 +77,7 @@
         prepare();
 
         try {
-            DataObject o2 = DataObjectUtils.objectForPK(context, Manager.class, 2);
+            Manager o2 = (Manager) DataObjectUtils.objectForPK(context, Manager.class, 2);
             assertTrue(o2 instanceof CAY_207Manager2);
 
             Object p2 = o2.readProperty("clientContactType");
@@ -100,8 +99,10 @@
 
         try {
             // M1
-            DataObject o1 = DataObjectUtils
-                    .objectForPK(context, CAY_207Manager1.class, 1);
+            Manager o1 = (Manager) DataObjectUtils.objectForPK(
+                    context,
+                    CAY_207Manager1.class,
+                    1);
             assertTrue(o1 instanceof CAY_207Manager1);
 
             Object p1 = o1.readProperty("clientContactType");
@@ -123,8 +124,10 @@
         prepare();
 
         try {
-            DataObject o2 = DataObjectUtils
-                    .objectForPK(context, CAY_207Manager2.class, 2);
+            Manager o2 = (Manager) DataObjectUtils.objectForPK(
+                    context,
+                    CAY_207Manager2.class,
+                    2);
             assertTrue(o2 instanceof CAY_207Manager2);
 
             Object p2 = o2.readProperty("clientContactType");



Mime
View raw message