Hello,
I've tried to use the extend attribute to map to classes Base and Extended
to only one table. The Base class holds basic fields like id, name ... the
Extended class holds more complex fields like collections for 1:n mappings.
Both classes share the same table and identites.
If you try to load an instance of Base with the identity 1 e.g. and then
load an instance of Extended with the same identity in the SAME transaction
you get:
org.exolab.castor.jdo.PersistenceException: Requested to load/fetch an
object of type Extended, where persistent storage returned an object of type
class Base
at org.exolab.castor.persist.TransactionContext.load(Unknown Source)
at org.exolab.castor.persist.TransactionContext.load(Unknown Source)
at org.exolab.castor.jdo.engine.DatabaseImpl.load(Unknown Source)
at org.exolab.castor.jdo.engine.DatabaseImpl.load(Unknown Source)
at de.cinetic.TestJdo.main(TestJdo.java:45)
The same code runs well if the two loads are NOT in the same transaction.
db.begin();
Base base = (Base)db.load( Base.class, new Integer(1));
System.out.println( base.toString() );
// comment this out, and an exception will occour
db.commit();
db.begin();
Extened extended = (Extended)db.load( Extended.class, new Integer(1));
System.out.println( extended.toString() );
db.commit();
If you change the order of the load calls (first load Extended and then
Base) the
same effect happens, but without causing an exception, since every
"Extended" is also
a "Base".
Nevertheless this is a bit confusing and requires special care when using
this type
of mapping. Any hints to deal with this effect/bug?
Stefan
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev