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 Brian Gebala <br...@gebala.net> on 2003/08/14 20:59:52 UTC

RC4 Cache/Sequence ?

I'm using OJB"s JDO plug-in and am having some problems regarding the
caching/sequencing of an object.

 

I obtain a User object with id=1 from the users table via this bit of
code:

 

PersistenceManagerFactory factory = new OjbStorePMF(); // this is only
done once in the servlet's init() method.

PersistenceManager manager = factory.getPersistenceManager();

Transaction tx = manager.currentTransaction();

tx.begin();

PersistenceBroker broker =
PersistenceBrokerFactory.defaultPersistenceBroker();

User user = new User();

User.setId(1);

Identity oid = new Identity(user, broker);

user = (User)manager.getObjectById(oid, false);

.

tx.commit();

 

Now I display this User's first name, etc. in a form. I submit the form
to change the first name.  (When submitting, I go thru the same steps to
get the user, call user.setFirstName(), and commit the transaction.) If
I back-button to the form, reload, I get null's in each of the form
fields. This will happen unless I explicitly clear the cache with a call
to PersistenceBrokerFactory.defaultPersistenceBroker().clearCache().
Clearing the cache in this manner seems to defeat the purpose of the
cache.

 

As a side note, I am using ObjectCacheDefaultImpl and modified it so as
to print the args passed to lookup(), clear(), cache(), and remove().
When I look up the object in the first place, I see two cache() calls,
one for a number which is not the id I specifiy (which differs depending
on which SequenceManager impl I use), then finally the cache call for
the id I specified.

 

Am I missing something here, or is this behavior due to the fact that
the OJB JDO facility is at best a hack?