i have read through numerous past posts about the "Timestamp mismatch!" problem with long transactions, but can't understand what is happening.

basically, i have 2 servlets, ServletA and ServletB.

ServletA retrieves an existing User from the database as follows:

        db.begin();
        OQLQuery query = db.getOQLQuery(OQL_FIND_BY_LOGINID);
        query.bind(data.getLoginId());
        QueryResults results = query.execute();
        if( results.size() > 1 ) {
                throw new PMException("More than 1 object was returned.");
        }
        User user = null;
        while( results.hasMore() ) {
                user= (User)results.next();
        }
        db.commit();

then this User object is stored in the session.

req.getSession().setAttribute("user", user);


later, ServletB retrieves the user from the session and attempts to Castor-update() it as follows:



db.begin(); User user = (User)req.getSession(false).getAttribute(SessionAttributes.USER); -> db.update(user); // getting "Timestamp mismatch!" here ... // also, another persistable object tries to user the User object Order order = new Order(); order.setUser(user); db.create(order); db.commit();


the User class implements the org.exolab.castor.jdo.TimeStampable interface and the pertinent part of the mapping.xml definition for the User object is as follows:


  <class name="User"
         identity="id"
         access="shared"
         key-generator="UUID"
         auto-complete="false">
    <map-to
                        table="usr"
        />
        <cache-type
                type="count-limited"
        />
     ...
   </class>


i have read in the posts that the default count-limited is 100, and i have not performed many database transactions to be even close to the limit of 100.


the workaround that i'm using to temporarily solve the problem is:

        User user  = (User)req.getSession(false).getAttribute("user");
        user = (User)db.load(User.class,user.getId());

but i would like to understand why db.update(user) is not working?

thank you.

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




Reply via email to