See below


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of marc
> fleury
> Sent: Wednesday, June 13, 2001 10:53 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [JBoss-dev] Should CacheKey copy its id on creation?
>
>
> 1- TURN OFF HTML!!!!!!!!!!!!!!!!!!!!!!!!

Yeah, sorry, Outlook seems to do this sometimes without warning....

> 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)"

Yeah sorry, it should of read that way..Typo...

> 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

True, the HashMap lookup is correct because of the MarshalledObject stuff.
But, in the above example code for Optimized = true, listOfIds.length number
of beans all share the same instance of the PrimaryKey passed in to
findByPrimaryKey, that is, the CacheKey.id instance AND the
EnterpriseContext.id instance!!!  So when the CMP EntityBean does a store,
it will lookup on a bad PrimaryKey.

> 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.
>

Again, CacheKey.equals DOES work. But the PrimaryKeys are all shared.

> ---------------------
> 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.
>
>

If you don't believe it, how come when we turned off Optimized everything
worked.  As a different test, we didn't share PrimaryKey instances when
calling findByPrimaryKey, and that worked as well!  I'm not crazy here.
I've been looking at this code for more than a week now trying to figure out
why our InstanceCache was all fucked up and finally, finally found the
solution.  BTW, the Optimized flag isn't even documented within JBoss.....


> ---------------------
>   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.
>

No problem man.  This is why I sent out the e-mail asking if anybody
objected!  :-)

Later,

Bill

> marcf
>
> and please turn OFF the freaking HTML
>
>
>
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-development
>



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

Reply via email to