i have a fix/hack for this problem which involves some modifications of
four classes:
persist.TransactionContext, persist.OID, persist.ClassMolder,
jdo.engine.SQLEngine

with this modification, depended classes can create dependant classes
with just a many-key mapping.

the solution does not account for multiple foreign keys nor does it
account for non-dependant classes (which isn't a problem, i think).

i'll summarize my solution to the problem below.  i'm not sure what the
process/policy is for sharing modified source code, but i'd be more than
happy to provide my changes...

- SQLEngine has been modified to define a foreign key ColumnInfo and
corresponding statement parameter when a depended class exists.

- SQLEngine.create() has been overloaded to accept a fourth parameter,
dependedIdentity, which is then bound to the create statement if the
foreign key ColumnInfo exists.

- ClassMolder.create() has been modified to pass a fourth parameter,
dependedIdentity, to the underlying SQLEngine.  This is done using
oid.getDepends().getIdentity().

- OID was given setDepends() and _depends was unfinalized. this was done
so that TransactionContext can update dependencies.

- TransactionContext.rehash(), which reassigns an object to a new oid,
now updates the dependant oid references.  this is necessary for the
modified ClassMolder.create to work in the case of nested new objects.


this works for me, but does it break other things?

thanks,
-ed

 

-----Original Message-----
From: John Wang [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 20, 2001 5:37 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] foreign key assignment for dependant objects


I have the same problem as you, I have asked the question too, "
Why use add***() on the primary object don't update the foreign key on
the
foreign table?

and I think it is a bug, itsn't it?


----- Original Message -----
From: "Edward Hicks" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 19, 2001 10:01 AM
Subject: [castor-dev] foreign key assignment for dependant objects


> I have 2 classes: Article and dependant class Segment. a Segment
> collection is mapped to Article with <sql many-key="articleid">
>
> without having to map the foreign key column "articleid" to a field in
> Segment, castor can load an Article along with the Segment collection
> just fine.  this is good.
>
> going the other way, i wanted to be able to modify the Segment
> collection of an Article, adding new Segment instances, and persist
the
> Article back to the database with db.update().
>
> castor does create new Segments in the database, but doesn't write the
> Article id into the foreign key column.  it seems castor should be
able
> to do this in the case of dependant classes.
>
> i hunted around the mail archives, but couldn't find anything on this.
> i also looked in the persistence source code, but only found
dependency
> checking for superclasses.
>
> is there any way castor can perform this update successfully without
> having to map the fields for foreign keys?
>
> i'm specifically trying to avoid mapping foreign key fields so as to
> decouple the java classes from the relational tables as much as
> possible.
>
> thanks,
> ed hicks
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to