Hi,
> -----Urspr�ngliche Nachricht-----
> Von: Andrey Chernyh [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 25. September 2002 08:16
> An: [EMAIL PROTECTED]
> Betreff: Dirty flag on save? Storing collection with
> unchanged objects.
>
>
>
> Hi All!
> I have object System, it has collection of SubSystems.
> When I create new SubSystem, I add it to System's collection.
>
>
> tx.begin();
>
> System system = getByIdentity( 1, System.class );
> Collection subSystems = system.getSubSystems();
> subSystems.add( new SubSystem() );
>
> tx.commit();
>
> After saying commit, ALL(!) objects in subSystems collection are
> updated. I think it's not good. What can you say about it?
>
1. Only ODMG collections like DList provide full transaction integration.
2. the ODMG transaction does execute SQL commands for all objects locked to
the transaction.
If all elements of the collection are locked and edited inside the
transaction OJB will perform updates.
If they are locked but not touched during the transaction they will be still
marked "clean" and no update will be executed.
>
> PersistentBorekerImpl:
> private void store(Object obj, boolean insert, Map markedForStore)
> {
> ......
> storeCollections(
> obj,
> cld.getCollectionDescriptors(),
> markedForStore);
> }
>
> storeCollections() iterates over all objects in collection, and stores
> all the objects in it. :(
> May be the dirty check mentioned below will help?
>
The tx.begin() ... tx.commit() snippet is using ODMG Api.
the stuff you are quoting here is from The PB.
ODMG and PB are quite different.
The dirty check you mention *is done* on the ODMG level.
this is functionality covered by regression tests!
cheers,
Thomas
>
> Thomas Mahler wrote:
> >Hi Winson,
>
> >The layerered approach of OJB delegates such optimizations
> to the high
> >level APIs ODMG, JDO and OTM.
> >That is on the PersistenceBroker there is no such tracking.
> >But on the ODMG and JDO level you have full object level
> transactions.
> >There is some further explanation on this topic in the FAQ.
>
> >The PersistenceBroker provides the notion of an
> ObjectModification that
> > contains hint information if an object needs insert or update.
>
> >So IMO there no need to add anything.
>
> >cheers,
> >Thomas
>
> >Winson Quock wrote:
> > Hello,
> >
> > Looks like to me that OJB allows configuration of whether
> to store a related
> > object automatically, but it does not attempt to figure out
> if the related
> > objects are changed, i.e. we need some kind of dirty-flag
> mechanism, for
> > optimization.
> >
> > I suggest we add an interface "ChangeTrackedObject" like
> >
> > interface ChangeTrackedObject {
> > bool isChanged();
> > }
> >
> > when we store we check if we can:
> >
> > if (obj instanceof ChangeTrackedObject) {
> > if (!((ChangeTrackedObject)obj).isChanged()) {
> > // no change
> > return;
> > }
> > }
> >
> > The data object is responsible for tracking the changes.
> >
> > What do you think?
> >
>
>
>
>
>
> Best regards,
> Andrey Chernyh<[EMAIL PROTECTED]>
> Plesk Inc.
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>