> Basically, it is doing what someone had previously recommended about copying
> data from existing object to a newly created transaction object ("freshObj" in
> my code).  I use Castor's FieldMolder to copy the values, and the only
> "special/custom" stuff for me is the "getNonTransactionalIdentity()".

Does this work well for you? I'm pretty sure it would have problems with any
fields that are PERSISTANCECAPABLE (ie. fields that are objects in your mapping
file). But you could probably get around that by calling db.load() on those
fields like you do to load freshObj in the first place. And I guess you'd have
to code up something similar for collection fields of PERSISTANCECAPABLE
objects....

Another thing, Castor can do your getNonTransactionalIdentity for you AFAIK.
Here's my routine that performs this genericly (although I don't know enough
about Castor to garuntee it's going to work).

  private Object loadJdo( Object jdoObject, Database database )
    throws PersistenceException
  {
    if ( jdoObject != null ) {
      return database.load( jdoObject.getClass(),
       database.getScope().getPersistenceInfo( jdoObject.getClass()
).molder.getActualIdentity( database.getClassLoader(), jdoObject ) );
    } else {
      return null;
    }
  }

> NOTE: This code will not flag any changes in db from
> BEFORE it was called, so (at the moment) it will overwrite any changes made
> outside Castor, and any changes made after original "obj" created, but before
> "freshObj" is loaded.

Good, because that's exactly what I want :)

> I'm sure this could be improved, but I'm still learning Castor.  Hope this
> helps you.

It did thanks. Hope the advice above is helpful in return.

Damon.

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

Reply via email to