Hi Lance,
what version of OJB do you use?
The cache package was refactored some
weeks ago.
You could use current CVS (run test cases to check
stability) or last release.
regards,
Armin
----- Original Message -----
From: "Lance Eason" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, March 14, 2003 6:28 PM
Subject: RE: Transactional isolation at the object layer
I don't seem to be getting any different behavior. Looking at
ObjectCacheFactory:
public class ObjectCacheFactory extends ConfigurableFactory
{
private static ObjectCacheFactory INSTANCE = null;
private ObjectCache CACHE = null;
public static ObjectCacheFactory getInstance()
{
if (INSTANCE == null)
{
INSTANCE = new ObjectCacheFactory();
}
return INSTANCE;
}
public ObjectCache createObjectCache(PersistenceBroker broker)
{
if (CACHE == null)
{
There's only a single ObjectCacheFactory stored as a static instance and
it holds a single instance of a cache, so there's still only one global
cache. Shouldn't the createObjectCache method create a new cache every
time or at least one per broker? ObjectCacheDefaultImpl is already
maintaining a static map so it wouldn't have any impact on it, it would
still act as a global cache but it would mean that
ObjectCachePerBrokerImpl would work as intended.
-----Original Message-----
From: Thomas Mahler [mailto:[EMAIL PROTECTED]
Sent: Friday, March 14, 2003 1:15 AM
To: OJB Users List
Subject: Re: Transactional isolation at the object layer
Hi Lance,
By default OJB uses one large global cache.
To achieve proper isolation you have to tell OJB to use one cache per
Broker:
In OJB.properties you have to configure to use
org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl
as objectcache implementation
cheers,
Thomas
Lance Eason wrote:
> I'm using 1.0 rc1 with the PB API. I'm noticing that I don't have any
isolation between multiple brokers when caching is enabled. For
example:
>
> Object[] pk = new Object[] {new Long(42)};
> Identity id = new Identity(Article.class, pk);
>
> PersistenceBroker broker1 =
PersistenceBrokerFactory.defaultPersistenceBroker();
> broker.beginTransaction();
>
> Article a1 = (Article) broker.getObjectByQuery(new
QueryByIdentity(id));
> a1.articleName = "My article";
>
> // start a second transaction
> PersistenceBroker broker2 =
PersistenceBrokerFactory.defaultPersistenceBroker();
> broker2.beginTransaction();
>
> Article a2 = (Article) broker.getObjectByQuery(new
QueryByIdentity(id));
> // a2 is another reference to the same Article as a1
> a2.unit = "kg";
>
> broker2.abortTransaction();
>
> broker.store(a1, ObjectModificationDefaultImpl.UPDATE);
> broker.commitTransaction();
>
> broker2.close();
> broker.close();
>
> The changes that I made on the aborted broker2 transaction end up
getting persisted on the broker1 transaction because they're sharing the
same object reference. Similarly changes made on other transactions are
visible even before they're committed. In general it doesn't look like
I have any transactional isolation if caching is turned on. I guess my
gut expectation was that caches would be broker specific and there would
be communication between caches to coordinate invalidations on updates
and deletes.
>
> So how do other people deal with this? I had thought maybe I could
manage two jdbc-connection-descriptors pointing to the same database,
one with a cache used only for reads and another with caching turned off
used for updates but it looks like the caching policy is global not on a
per descriptor basis. Am I missing something obvious?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]