1- TURN OFF HTML!!!!!!!!!!!!!!!!!!!!!!!!
2- see below



 -----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Bill
Burke
Sent: Wednesday, June 13, 2001 8:47 AM
To: Jboss-Development@Lists. Sourceforge. Net
Subject: [JBoss-dev] Should CacheKey copy its id on creation?


All,

We ran into a problem where our Entity cache was getting corrupted and
findBy's were returning a bean other than the one we queried for.  With
"Optimized" set to true in standardjboss.xml, we were re-using a PrimaryKey
for multiple findByPrimaryKey calls.

// pseudo code
---begin transaction

public ArrayList getMoney(long[] listOfIds)
{
ArrayList rtn = new ArrayList();
MoneyPK pk = new MoneyPK(0);  // create an instance of a primary key
for (int i = 0; i < listOfIds.length; i++)
{
    pk.id = listOfIds[i];
    Money m = home.findByPrimaryKey(pk);
    rtn.add(m);
}
}

// end pseudo code

Because parameters are not being copied(Optimized = false), the instance of
the PrimaryKey I pass into findByPrimaryKey is being shared by multiple
different CacheKeys that are supposed to reference different Entities.
--------------------------

This is an incorrect analysis,
1- you probably mean "are not being copied (optimized = true)"
2- you share the same instance of the PrimaryKey, yes, but the field
variables are not the same so that the byte representation should not be the
same, REGARDLESS of the adress of the key
3- So no the cache key should not reference the same thing.  What is wrong
is that we don't care about the "adress" of the object, just the values.  If
that is not what is compute in the cache key then that is wrong.

---------------------
IMHO, this is the right and safe way to do it.  I'm going to change
CacheKey, test changes, and commit if no one objects.
---------------------

I do object, hold on on that, I am not sure I believe your analysis at this
point, so I am certainly not going to buy a solution either (even tested),
it is core enough that we need to think about it.  Ping me tomorrow or
friday.


---------------------
  I'm also going to change CacheKey so that it's member variables are
immutable(make variable private and provide only get methods).
---------------------

same here, we need a clear picture of what is the problem before we go and
change CORE stuff in the cache.  I am not saying it is not broken, I never
say this, just that it's not clear right now.

marcf

and please turn OFF the freaking HTML



_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to