You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Schramm, Rich" <ri...@mbari.org> on 2003/05/03 00:48:09 UTC

RE: [patch] add method markDirty to TransactionImpl

I think I have the fix... could someone in authority tell me:
1) I am correct and if so..
2) please add this to the earlier patch.

In addition to the patch provided by "roger janssen" (implemented by Thomas) which added the markDirty method to  ..\db-ojb-1.0.rc2\src\java\org\apache\ojb\odmg\TransactionImpl.java 

I needed to modify two additional files an rebuild:

1) the interface ..\db-ojb-1.0.rc2\src\java\org\odmg\Transaction.java to include the line:

    public void markDirty(Object o); 

2) the only other class I could find that implemented the interface:
..\db-ojb-1.0.rc2\src\java\org\apache\ojb\odmg\NarrowTransaction.java  to which I added:

     /**
     * Not supported!!
     */
    public void markDirty(Object o)
    {
        throw new UnsupportedOperationException("Not supported operation");
    }


Thanks - Rich Schramm



-----Original Message-----
From: Schramm, Rich [mailto:rich@mbari.org]
Sent: Monday, April 28, 2003 3:53 PM
To: 'OJB Users List'
Cc: thma32@web.de
Subject: RE: [patch] add method markDirty to TransactionImpl


What do I need to do to add this to my code.. I tried to cut and paste into
 ..\db-ojb-1.0.rc2\src\org\apache\ojb\odmg\TransactionImpl.java 

Then I completely rebuild OJB using bin\build junit

But it is still not found when I try to use it - (as in snipit below)
Am I adding it in the wrong place or am I not using the right odmb transaction somehow?

Thanks - Rich Schramm

/****** code snipit ***/

package mypackage;
import myapp.*;
import org.apache.log4j.Logger;

import org.odmg.*;

import java.util.Collection;
import java.util.Vector;

public class UCDataContainerTests_1 extends AbstractUseCase
{
    static Logger logger = Logger.getLogger(UCDataContainerTests_1.class);

    public  UCDataContainerTests_1(Implementation impl)
    {
        super(impl);
    }

    /** perform this use case*/
    public void apply()
    {
       Transaction tx = null;
       OQLQuery query = null;
       String queryString;

  	 queryString = "select dp from " + DataProducer.class.getName() + " where id = 698"; 
       try
        {
            tx = odmg.newTransaction();
            tx.begin();

            query = odmg.newOQLQuery();
            query.create(queryString);

            DList result = (DList) query.execute();
            DataProducer myDataProducer = (DataProducer) result.get(0);

//here is the call that cant be found........

            tx.markDirty(myDataProducer);

	      DataContainer myDataContainer = new DataContainer ();
	      myDataContainer.setName(myDataProducer.getName());
            tx.lock(myDataContainer, Transaction.WRITE);

            myDataProducer.addOutput(myDataContainer);
            tx.lock(myDataProducer, Transaction.WRITE);

            tx.commit();

            logger.debug(myDataProducer.listAllDataContainers());
        }
        catch (Throwable t)
        {
            // rollback in case of errors
           // tx.abort();
            t.printStackTrace();
         }

-----Original Message-----
From: David.Corbin@equifax.com [mailto:David.Corbin@equifax.com]
Sent: Friday, April 18, 2003 11:13 AM
To: OJB Users List
Cc: OJB Users List; thma32@web.de
Subject: Re: [patch] add method markDirty to TransactionImpl



(1) is a bug tha I identified and reported a week or two ago.  I hope the
original bug will still be addressed.

David



|---------+--------------------------->
|         |           Thomas Mahler   |
|         |           <th...@web.de> |
|         |           Sent by:        |
|         |           thma32@web.de   |
|         |                           |
|         |                           |
|         |           04/18/2003 01:38|
|         |           PM              |
|         |           Please respond  |
|         |           to "OJB Users   |
|         |           List"           |
|         |                           |
|---------+--------------------------->
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                                  |
  |        To:      OJB Users List <oj...@db.apache.org>                                                                                          |
  |        cc:                                                                                                                                       |
  |        Subject: Re: [patch] add method markDirty to TransactionImpl                                                                              |
  |                                                                                                                                                  |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|



Done !
thanks for the patch,
Thomas

Janssen, Roger wrote:
> hi,
>
> i have patched TransactionImpl, but cannot send it to this list (filezise
to
> big).
>
> the patch only consist of the addition of on method:
>
>     /**
>      * marks an object as dirty
>      * @param  anObject Object to be marked
>      */
>     public void markDirty(Object anObject)
>     {
>         ObjectEnvelope otw = objectEnvelopeTable.get(anObject);
>         otw.setModificationState(otw.getModificationState().markDirty());
>     }
>
> can anybody apply this path to the cvs-head.
>
> reason for patch:
>   (1) when i try to store an object that has been modified,
>   it will not be stored when the modified attribute is
>   a collection (f.i. a vector of strings), because ojb
>   will not mark the object as dirty.
>   (2) i need to be able to explicitly mark an object
>   as dirty within a transaction so it will be saved
>
> workaround for (1):
>   the ability to explicitly mark an object as dirty
>   within a transaction
>
> added value (2):
>   it now becomes possible to modify an object outside a
>   transaction, then begin a transaction, explicitly mark
>   the object as dirty, and the modifications are stored.
>   previously, all modifications had to be made inside a
>   transaction.
>   i have several cases where the processing of input data,
>   the application of businessrules on the data, and the
>   actual saving of the modified data are done seperately
>   in different components, where our persistence component
>   has no knowledge of the object to save. this scenario can
>   only be implemented nicely, when i can modify objects
>   outside a transaction.
>   it does not undermine the ODMG spec since you still have to
>   mark the object dirty within the transaction.
>
> are there any objections to this patch?
>
> thanx,
>
> roger janssen
>
>
>
> *************************************************************************
> The information contained in this communication is confidential and is
> intended solely for the use of the individual or entity to  whom it is
> addressed.You should not copy, disclose or distribute this communication
> without the authority of iBanx bv. iBanx bv is neither liable for
> the proper and complete transmission of the information has been
maintained
> nor that the communication is free of viruses, interceptions or
interference.
>
> If you are not the intended recipient of this communication please return
> the communication to the sender and delete and destroy all copies.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org







---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org