Hi Nick,

I'll take the test home and try to execute it later.

Ralf


Nick Stuart schrieb:
Ok, got it to fail using a very simply test case. Attached the patch
to the current test case as well as the extra object I created. If you
run it you should get the following exception:
org.exolab.castor.jdo.PersistenceException: Requested to load/fetch an
object of type jdo.test1158.ExtendedObject, where persistent storage
returned an object of type class jdo.test1158.BaseObject

The problem is that it sees the parent of DependentObj as being loaded
because BaseObject is loaded. And when it goes to try and load the
ExtendedObject it just gets all confused. Not sure what the design for
this is, but it looks like you are loading BaseObject seperatly first,
then, if you find an extended object if you find a class that extends
BaseObject with the same ID and replacing it? Not sure one this one.

-Nick


------------------------------------------------------------------------

Index: src/tests/jdo/test1158/ExtendedObject.java
===================================================================
RCS file: 
/home/projects/castor/scm/castor/src/tests/jdo/test1158/ExtendedObject.java,v
retrieving revision 1.1
diff -u -r1.1 ExtendedObject.java
--- src/tests/jdo/test1158/ExtendedObject.java  8 Aug 2005 18:58:09 -0000       
1.1
+++ src/tests/jdo/test1158/ExtendedObject.java  10 Aug 2005 17:42:17 -0000
@@ -15,7 +15,16 @@
  */
 public class ExtendedObject extends BaseObject {
     private String _description2;
+    private DependentObj dependent;
public String getDescription2() { return _description2; }
     public void setDescription2(String description2) { _description2 = 
description2; }
+
+    public DependentObj getDependent() {
+        return dependent;
+    }
+
+    public void setDependent(DependentObj dependent) {
+        this.dependent = dependent;
+    }
 }
Index: src/tests/jdo/test1158/Test1158.java
===================================================================
RCS file: 
/home/projects/castor/scm/castor/src/tests/jdo/test1158/Test1158.java,v
retrieving revision 1.1
diff -u -r1.1 Test1158.java
--- src/tests/jdo/test1158/Test1158.java        8 Aug 2005 18:58:09 -0000       
1.1
+++ src/tests/jdo/test1158/Test1158.java        10 Aug 2005 17:38:54 -0000
@@ -40,13 +40,16 @@
             Database db = manager.getDatabase();
             db.begin();
             try {
-                db.load(ExtendedObject.class, new Integer(1));
+                ExtendedObject obj = (ExtendedObject)db.load(BaseObject.class, 
new Integer(2));
                 db.commit();
+                assertNotNull(obj);
+                assertNotNull(obj.getDependent());
                 db.close();
-                fail();
-            } catch (ClassCastException e) {
+ + } catch (ClassCastException e) { db.rollback();
                 db.close();
+                fail();
             }
         } catch (PersistenceException e) {
             e.printStackTrace();
@@ -64,10 +67,12 @@
                 obj1.setDescription2(obj1.getDescription2() + " - 1");
                 db.commit();
                 db.close();
-                fail();
+ } catch (ClassCastException e) {
+                e.printStackTrace();
                 db.rollback();
                 db.close();
+                fail();
             }
         } catch (PersistenceException e) {
             e.printStackTrace();
Index: src/tests/jdo/test1158/create.sql
===================================================================
RCS file: /home/projects/castor/scm/castor/src/tests/jdo/test1158/create.sql,v
retrieving revision 1.1
diff -u -r1.1 create.sql
--- src/tests/jdo/test1158/create.sql   8 Aug 2005 18:58:09 -0000       1.1
+++ src/tests/jdo/test1158/create.sql   10 Aug 2005 14:06:17 -0000
@@ -18,3 +18,14 @@
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO test1158_object VALUES (1, 'This is the test object.', '');
+
+DROP TABLE IF EXISTS test1158_depends;
+
+CREATE TABLE test1158_depends (
+  id           int NOT NULL default '0',
+  parentId           int NOT NULL default '0',
+  description  varchar(50) NOT NULL default '',
+  PRIMARY KEY (id)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+INSERT INTO test1158_depends VALUES(1, 1, 'This is a description');
Index: src/tests/jdo/test1158/test1158-mapping.xml
===================================================================
RCS file: 
/home/projects/castor/scm/castor/src/tests/jdo/test1158/test1158-mapping.xml,v
retrieving revision 1.1
diff -u -r1.1 test1158-mapping.xml
--- src/tests/jdo/test1158/test1158-mapping.xml 8 Aug 2005 18:58:09 -0000       
1.1
+++ src/tests/jdo/test1158/test1158-mapping.xml 10 Aug 2005 16:37:38 -0000
@@ -26,5 +26,23 @@
         <field name="description2" type="string">
             <sql name="description2" type="varchar"/>
         </field>
+        <field name="dependent" type="jdo.test1158.DependentObj">
+            <sql many-key="parentId"/>
+        </field>
     </class>
+ + <class name="jdo.test1158.DependentObj" identity="id" depends="jdo.test1158.ExtendedObject" key-generator="IDENTITY">
+        <map-to table="test1158_depends"/>
+        <cache-type type="unlimited"/>
+        <field name="id" type="integer">
+            <sql name="id" type="integer"/>
+        </field>
+        <field name="parent" type="jdo.test1158.ExtendedObject">
+            <sql name="parentId"/>
+        </field>
+        <field name="description" type="string">
+            <sql name="description" type="varchar"/>
+        </field>
+    </class>
+ </mapping>


------------------------------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to