Hi Bruce,
//the tx context above is never made aware of the testEntry object. Because each tx above contain separate contexts, you must make use of long transactions whereby an object is read in the first tx and persisted in the second tx. In order to bridge the gap between each tx, the objects involved must implement org.exolab.castor.jdo.TimeStampable to hold a timestamp for dirty checking. Please see the following doc for more information on this concept:   http://www.castor.org/long-transact.htmlAlso, be sure to let us know if you have further questions in resolving this issue.
//Bruce

 

 

I did the changes as you said which includes

 

1.             Implementing the implement org.exolab.castor.jdo.TimeStampable in the
 Object
2.             Define dirty checking capabilities for the Object in the mapping file by doing  <cache type cache="time-limited" capacity="1000"/> for the Object.
 

After doing these I thinks  my client class is capable of handling the Transaction Context issue as you said. (Am I missing something in the client implementation..?)  But unfortunately this did not help me and it still fails to update object with no error stack.

 

Here is the code for the client, mapping, and the Object.   Please get back to me regarding this.

 

 

CLIENT:

 

public  synchronized void doReflectionTest()

    {

        String servletError="test_error.log"; 

        try{

           errorlog=new PrintStream(new FileOutputStream(servletError,true), true);

        }

        catch(Exception ex){

          System.out.println(ex.getMessage());

        }

 

        DBThread  dBThread = new DBThread(new DBPool(errorlog,props),errorlog);

        try{    

              dBThread.start();

              System.out.println("Starting the Castor engine ..");

              while(! dBThread.isFinish()){

                  System.out.println("wait...");

                  this.wait(1000);

              }

        }

        catch(Exception e){

            System.out.println("Error in starting the thread: "+e.getMessage());

            errorlog.println("Error in starting the thread: "+e.getMessage());

        }

        try{      

            dBThread.getDb().begin();  

            OntologyEntry testEntry=new OntologyEntry();

            testEntry.setCategory("TestCategory2");

            testEntry.setValue("TestValue2");

            dBThread.getDb().create(testEntry);

            dBThread.getDb().commit();

 

            dBThread.getDb().begin();  

            String oql="select e from MAGE.OntologyEntry e where id=190115";

            OQLQuery oQLQuery=dBThread.getDb().getOQLQuery(oql);

            QueryResults queryResults=oQLQuery.execute();

            OntologyEntry >

            while(queryResults.hasMore()){

              style="mso-spacerun: yes">   

              System.out.println("Category  :  "+ontologyEntry.getCategory() +"  Value :  "+ontologyEntry.getValue());

              System.out.println("Id of new Ontology: "+testEntry.id);

              ontologyEntry.associations=new Vector();

              ontologyEntry.associations.add(testEntry);

            } 

            dBThread.getDb().commit();

            dBThread.submitDb();

        }

    

        catch(Exception e){

            System.out.println("[Exception is here :]"+e.getMessage());

        }

    }

 

 

 

 

MAPPING:

 

<class name="MAGE.OntologyEntry"

             identity="id" key-generator="SEQUENCE" >

<cache-type cache="time-limited" capacity="1000"/>

<map-to table="TT_OntologyEntry"/>

<field   name="id" type="big-decimal">

            <sql name="ID" type="numeric"/>

</field>

<field  direct="true"  name="category" type="string">

            <sql name="category" type="varchar"/>

</field>

<field  direct="true"  name="value" type="string">

            <sql name="value" type="varchar"/>

</field>

<field  direct="true"  name="description" type="string">

            <sql name="description" type="varchar"/>

</field>

<field  direct="true"  name="ontologyReference" type="MAGE.DatabaseEntry">

            <sql name="ontologyReference_ID"/>

</field>

<field  direct="true" name="associations" type="MAGE.OntologyEntry"

             collection="vector">

<sql many-table="TT_association_T_OntologyE"

             many-key="T_OntologyEntry_ID"

             name="associations_ID"/>

</field>

</class>

 

 

OBJECT:

 

 

package MAGE;

public class OntologyEntry extends MAGEelement {

 

public String category;

public String value;

public String description;

 

public DatabaseEntry ontologyReference;

 

public Vector associations = new Vector();

 

 

 

static public boolean cacheEnabled = false;

static public Hashtable cache;

public OntologyEntry() {}

 

OntologyEntry(Attributes atts) {

super(atts);

..

.. �// Every thing Correct Here.//

   // No Castor related code�

..

}

}

 

 

public class MAGEelement implements Persistent, TimeStampable, Serializable {

 

 

   

    public BigDecimal id;  

    String identifier;

    public long DBId = 0;         

    public String roleName;

 

    public String parentClassList = "";

    long timeStamp;

 

    public String getClassName() {return "MAGEelement";}

 

    static LinkedList tempList = new LinkedList();

    �.

    �// Every thing Correct Here.//

        // No Castor related code�

    �.

   }

 

 


Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now

Reply via email to