Hello once more,

Like I said , before starting to use long transactions try to find a to make
it work reliable.
In our project we have about 40 tables and I lost about the work of a month
dealing with unreproducible errors.
Either castor did "loose" some objects (setAutostore(false) ) or it did
"sometimes" create duplicate objects  when it shouldn't(setAutoStore(true) )
My workaround of calling db.update() on all related objects in the
jdoPersistent() Method made it work, saved the project (and my sanity,
career, life.... whatever).
There isn't much to add to the code snippet in the mail you replied to. I
left the other methods in the Persitent interface empty.


 Hello,
>
> I'm still having problems.
>
> I don't understand how to implement correctly the Persistent inteface.
>
> Julian Löffelhardt suggest calling an update() in the jdoPersistent()
function for all related objects/collections in every object implementing
the Persistent interface.
>
> I've read the code from TestPersistent.java and Persistent.java in the
src/tests/jdo directory of the Castor CVS, and they implement it in a
different way...
>
> Here's my problem:
> I have an Object A
> A has a collection of B's. B depends on A (in the mapping.xml file)
> A has a related object C, not dependent.
> A has a related object D, not dependent.
> B has a related object C, not dependent.
>
>
> All of these implement the TimeStampable interface. I will deploy them in
Tomcat + Struts.
>
> Relations are bi-directional, as suggested in the mailing-list. I'm sure
is not a problem of my mapping file (no lazy loading, cacha enabled).
>
> My problem is sililar to this one:
> http://www.mail-archive.com/castor-dev@exolab.org/msg02687.html
>
> My questions are:
>
> - Would it be sufficient to just implement these update() calls ONLY in
the jdoPersistent() function? Not in the other functions of the Persistent
interface?
> - Doesn't the setAutoStore(true) do the same thing? I'm very confused with
this function, when I enable it, it creates duplicate entries in the
database, of objects i'm updateing.
> - Can you give me a more detailde example, and maybe some source code?
>
>
> Here's is the original message:
>
> --------------------------------------------------------------------------
------
> From: Julian Löffelhardt
> Subject: Re: [castor-dev] unable to call update
> Date: Mon, 07 Jan 2002 14:51:51 -0800
> --------------------------------------------------------------------------
------
>
> e.g.:
>
> class A implements Persistent{
>     protected List listB;
>     .
>     .
>     public void jdoPersistent( Database db ){
>         Iterator it=listB.iterator();
>
>
it.hasNext()){ 
>             B b =(B)it.next();
>             if (!db.isPersistent(b)) db.update(b); 
>     }
> }
> class B implements Persistent{
>     protected A a;
>     .
>     .    
>     public void jdoPersistent( Database db ){
>         if (!db.isPersistent(a)) db.update(a);
>     }
> }
> 
> Castor enforces the persistence of classes only towards the parent of relations, you 
> could update A without updating all it's B's. But I've seen many cases of misterious 
> errors e.g. the sudden loss of relations etc. which can be avoided if the whole 
>"web" 
> of connected classes is updated in the same transaction. Since I always update all 
> related objects Castor works great.
> 
> julian
> 
> ----- Original Message ----- 
> From: "Ricardo Argüello" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, January 07, 2002 10:36 PM
> Subject: Re: [castor-dev] unable to call update
> 
> 
> > Please elaborate...
> > 
> > I'm having the same problem. I don't understant how should I implement the 
> >jdoUpdate() function body.
> > 
> > The documentation doesn't explain clearly what to do to map a 1:n not dependant 
> >relation.
> > Please try to give a more datailed explanation.
> > 
> > Thanks in advance.
> > 
> > 
> > ----- Original Message ----- 
> > From: "Julian Löffelhardt" <jul
@yy-mm-dd.com>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, January 07, 2002 1:09 PM
> > Subject: Re: [castor-dev] unable to call update
> >
> >
> > > Hi,
> > >
> > > The best way I found to avoid these (and many other) problems is:
> > > Each Object implements the interface Persistent.
> > > The callback function jdoUpdate is used to call update() on all
related
> > > objects if they aren't persistent yet.
> > >
> > > This way I avoid cluttering my business logic with 1-10 update() calls
every
> > > time I want to update asn object.
> > >
> > > What do you think about this solution?
> > >
> > > julian Löff
> elhardt
> > >
> > >
> > > ----- Original Message -----
> > > From: "Bruce Snyder" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Monday, January 07, 2002 6:34 PM
> > > Subject: Re: [castor-dev] unable to call update
> > >
> > >
> > > > This one time, at band camp, Christopher Cheng said:
> > > >
> > > > CC >[christopher] Castor: Loading com.netdimen.pms.employee.Employee
> (1)
> > > > CC >org.exolab.castor.jdo.PersistenceException: Object,
> > > > CC >com.netdimen.pms.employee.Em
> > > > CC >ployee@7d03c5, links to another object,
> > > > CC >com.netdimen.pms.employee.Position@2a13a
> > > > CC > that is not loaded/updated/created in this transaction
> > > > CC >
> > > > CC >        <field name="position"
> > > type="com.netdimen.pms.employee.Position">
> > > > CC >            <sql name="positionID"/>
> > > >
> > > > Christopher,
> > > >
> > > > Becasue of the mapping above for a field of type Position within
> > > > the Employee object, the field called position must be loaded.
> > > > Because Position does not depend on Employee, it will need to loaded
> > > > manually perhaps through the use of a getter.
> > > >
> > > > Bruce
> > > > --
> > > >
> > > > perl -e 'print
> > > unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
>
>
>
>

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

Reply via email to