Does anyone out there have any ideas as to why I am having so many problems
doing something that should be very straight forward?

Any and all help is GREATLY, GREATLY appreciated.

-----Original Message-----
From: Jamal Jackson 
Sent: Friday, April 19, 2002 4:54 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [castor-dev] Long Transaction still giving
ObjectModifiedExce ption


Thanks for the note.  I haven't set my object variables to anything yet,
including  "" .  So I imagine that the ones that were null from when I
loaded the object are still null

-----Original Message-----
From: Ebersole, Steven [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 11:38 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Long Transaction still giving
ObjectModifiedExce ption


Do not know if this is the cause of your problem or not, but we ran into a
similar issue using Oracle due to their infamous "empty string -> NULL"
feature (though most say bug) and Castor caching.

The idea is basically having a String attribute on your class set to ""
(empty string).  When you store this, Oracle WILL convert the empty string
to NULL.  So at this point the database contains NULL, but the cache
contains empty string.  Now when attempting to later update this object,
Castor will do the update  based on a WHERE clause where all the object's
mapped attributes are the same as in the database (to guard against
concurrent updates).  However, when querying where "" = NULL Oracle will
return false so the update fails because it appears the table has been
updated since you read your object.

This is a very fine nuance and was difficult to track down.




********************************************
Steve Ebersole
IT Integration Engineer
Vignette Corporation 
512.741.4195

Visit http://www.vignette.com

********************************************


-----Original Message-----
From: Jamal Jackson [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 1:09 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Long Transaction still giving
ObjectModifiedException


Thanks for the help in advance.


I created a test program that creates an object in one transaction and
updates it in the next, but it still throws an ObjectModifiedException.  I
don't understand how to fix this.

THIS IS MY MAIN METHOD FOR MY TEST CLASS ORMappingTest2

public static void main(String[] argv) {

        try {
                System.setProperty("pcorder.query","SELECT p FROM
com.satisfusion.ecommerce.model.EWPCOrderCreditCard p WHERE p.objectId=$1");
                ORMappingTest2 test2 = new ORMappingTest2();
                test2.init();

                System.out.println("Database begin called:
"+System.currentTimeMillis());

                EWPCOrder pcOrder = test2.process();
                System.out.println("About to begin TRANSACTION II");
                db.begin();
                //System.out.println("PCOrder is persistent:
"+db.isPersistent(pcOrder));
                //Object id = db.getIdentity(pcOrder);
                //System.out.println("Retrieved the objects identity: "+id);
                //EWPCOrder aPCOrder =
(EWPCOrder)db.load(pcOrder.getClass(),pcOrder.getObjectId());
                //System.out.println("aPCOrder is persistent:
"+db.isPersistent(aPCOrder));
                //String status = aPCOrder.getStatusof855();

                //System.out.println("The status is: "+status+"  The order
tracking number: "+aPCOrder.getOrderTrackingNumber());
                //aPCOrder.setStatusof855("Hey now");
                //db.update(aPCOrder);


                System.out.println("pcOrder is persistent:
"+db.isPersistent(pcOrder));
                pcOrder.setStatusof855("Hey now");
                db.update(pcOrder);
                System.out.println("pcOrder is persistent:
"+db.isPersistent(pcOrder));
                db.commit();
                System.out.println("Database commit called:
"+System.currentTimeMillis());
                System.out.println("Ending TRANSACTION II");
        }
        catch (Exception e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
        }

}



I LOAD MY JDO variables in my init method:

public void init() throws Exception {

        System.out.println("ORMappingTest2.init called");

        //INSTANTIATE DAO
        //CONNECT HERE TO THE DATABASE

        // Lookup databse in JNDI

        jdo = new JDO();
        jdo.setDatabaseName("ewdev2");

        jdo.setConfiguration("database.xml");
        jdo.setClassLoader(ORMappingTest2.class.getClassLoader());
        db = jdo.getDatabase();

        pcOrderDAO = new PCOrderDAO();
        pcOrderDAO.init(db);
        System.out.println("Created PCOrderDAO");

        pcOrderQuery = System.getProperty("pcorder.query");

        System.out.println("Running from the command line");

}


I PROCESS MY ORDER IN THIS METHOD


public EWPCOrder process() throws Exception{

        EWPCOrder pcOrder =
pcOrderDAO.findByPrimaryKey(pcOrderQuery,"SF-1008980755-11322");
        return pcOrder;
}


MY DAO CLASS IS VERY STRAIGHT FORWARD, THE FINDMYPRIMARYKEY METHOD IS:


public EWPCOrder findByPrimaryKey(String primaryKeyQuery, String value)
throws Exception {

        System.out.println("PCOrderDAO.findByPrimaryKey called");
        System.out.println("About to begin TRANSACTION I");
        database.begin();

        OQLQuery     oql;
        QueryResults results;
        EWPCOrder pcOrder = null;

        // Construct a new query and bind its parameters
        oql = database.getOQLQuery(primaryKeyQuery);
        oql.bind( value );
        // Retrieve results and print each one
        results = oql.execute();
        if (results.hasMore())
          pcOrder = (EWPCOrder)results.next();

        database.commit();
        System.out.println("Ending TRANSACTION I");
        return pcOrder;

}




AND LAST BUT NOT LEAST MY MAPPING FILE LOOKS LIKE:

<!--  Mapping for PCOrderCreditCardTable  -->
        <class name="com.satisfusion.ecommerce.model.EWPCOrderCreditCard"
extends="com.satisfusion.ecommerce.model.EWPCOrder"
                identity="objectId" key-generator="UUID">
                <cache-type type="unlimited"/>
                <description>PC Order</description>  
                
            <map-to table="ew_pcordercreditcard" xml="ewpcordercc" />  
    
            <field name="objectId">       
                        <sql name="objectId"/>
                        <!--  xml bind  -->
                        <bind-xml node="attribute"/>
                </field>
    
            <field name="createDate" type="date">
                        <sql name="CREATEDATE" type="date"/>
                        <bind-xml node="text" />
            </field>
    
            <field name="createBy" type="string">
                        <sql name="CREATEBY" type="varchar"/>
                        <bind-xml node="text" />
            </field>
    
            <field name="lastUpdate" type="date">
                        <sql name="LASTUPDATE" type="date"/>
                        <bind-xml node="text" />
            </field>
    
                <field name="lastUpdateBy" type="string">
                        <sql name="LASTUPDATEBY" type="varchar"/>
                        <bind-xml node="text" />
                </field>
    
                <field name="status" type="string">     
                        <sql name="STATUS" type="varchar"/>          
                        <bind-xml node="text" />
            </field>
    
            <field name="dateOrdered" type="date">      
                        <sql name="DATEORDERED" type="date"/>        
                        <bind-xml node="text" />
            </field>
    
            <field name="orderTrackingNumber" type="string">    
                        <sql name="ORDERTRACKINGNUMBER" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="dateProcessed" type="date">
                        <sql name="DATEPROCESSED" type="date" />
                        <bind-xml node="text" />
            </field>
    
            <field name="orderNumberSC" type="string">
                        <sql name="ORDERNUMBERSC" type="varchar" />
                        <bind-xml node="text" />
            </field>
    
            <field name="shipToName" type="string">     
                        <sql name="SHIPTONAME" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="shipToCompanyName" type="string">      
                        <sql name="SHIPTOCOMPANYNAME" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="shipToAddress" type="string">  
                        <sql name="SHIPTOADDRESS" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="shipToCity" type="string">
                        <sql name="SHIPTOCITY" type="varchar" />
                        <bind-xml node="text" />
            </field>
    
            <field name="shipToState" type="string">
                        <sql name="SHIPTOSTATE" type="varchar" />
                        <bind-xml node="text" />
            </field>
    
            <field name="shipToPostalCode" type="string">       
                        <sql name="SHIPTOPOSTALCODE" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="shipToPhone" type="string">    
                        <sql name="SHIPTOPHONE" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="shipToCountryKey" type="string">       
                        <sql name="SHIPTOCOUNTRYKEY" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="errorCode" type="string">
                        <sql name="ERRORCODE" type="varchar" />
                        <bind-xml node="text" />
            </field>
    
            <field name="overrideShipping" type="string">
                        <sql name="OVERRIDESHIPPING" type="varchar" />
                        <bind-xml node="text" />
            </field>
    
            <field name="shipToAddress2" type="string"> 
                        <sql name="SHIPTOADDRESS2" type="varchar" />

                        <bind-xml node="text" />
            </field>
    
            <field name="statusof855" type="string">    
                        <sql name="STATUSOF855" type="varchar" />

                        <bind-xml node="text" />
            </field>

                <field name="orderCreditCardType" type="string">        
                        <sql name="ORDERCREDITCARDTYPE" type="varchar" />

                        <bind-xml node="text" />
        </field>
        
        <field name="acctAccountOID" type="string">     
                        <sql name="ACCTACCOUNTOID" type="varchar" />

                        <bind-xml node="text" />
        </field>        

                <field name="creditCardInfoOID" type="string">
                        <sql name="CREDITCARDINFOOID" type="varchar" />
                        <bind-xml node="text" />
        </field>

                <field name="dateErrorEmailSent" type="date">
                        <sql name="DATEERROREMAILSENT" type="date" />
                        <bind-xml node="text" />
            </field>

        </class>


I GET THIS EXCPETION WHEN I RUN MY SAMPLE PROGRAM.

ORMappingTest2.init called
Created PCOrderDAO
Running from the command line
Database begin called: 1019237965045
PCOrderDAO.findByPrimaryKey called
About to begin TRANSACTION I
SET TIMESTAMP CALLED: 1019237965986
Ending TRANSACTION I
About to begin TRANSACTION II
pcOrder is persistent: false
GET TIMESTAMP CALLED: 1019237965986
pcOrder is persistent: true
Transaction aborted: Object of type
com.satisfusion.ecommerce.model.EWPCOrderCre
ditCard with identity SF-1008980755-11322 has been modified by a concurrent
tran
saction
org.exolab.castor.jdo.ObjectModifiedException: Transaction aborted: Object
of ty
pe com.satisfusion.ecommerce.model.EWPCOrderCreditCard with identity
SF-10089807
55-11322 has been modified by a concurrent transaction
        at org.exolab.castor.jdo.engine.SQLEngine.store(SQLEngine.java:867)
        at
org.exolab.castor.persist.ClassMolder.store(ClassMolder.java:1584)
        at org.exolab.castor.persist.LockEngine.store(LockEngine.java:758)
        at
org.exolab.castor.persist.TransactionContext.prepare(TransactionConte
xt.java:1457)
        at
org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:49
9)
        at com.satisfusion.test.ORMappingTest2.main(ORMappingTest2.java:109)


I HAVE FOLLOWED THE websites instructions on how to set it up long
transaction, but somehow this is just not working for me. Can any one see
what I am doing wrong?

Thanks again.



"Satisfying Customers by Fusing Sales & Service"!

The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain confidential or privileged information. If you are not the intended
recipient, please notify SATISFUSION, INC., immediately at 562.290.1300, or
the sender and destroy all copies of this message and any attachments.

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

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



"Satisfying Customers by Fusing Sales & Service"!

The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain confidential or privileged information. If you are not the intended
recipient, please notify SATISFUSION, INC., immediately at 562.290.1300, or
the sender and destroy all copies of this message and any attachments.

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

Reply via email to