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 Ernst Temp <Er...@gmx.at> on 2005/02/10 23:08:03 UTC
Cache errors?
Hello,
I am using OJB in my application (Mysql 4.1, Java 1.4.1, Mac OS X)
mainly as DB access layer. I am using the persistence broker, and had
strange behavior of the cache. It delivered table entries that were not
what i queried for.
Assume a table contents like
Key1 , key2 , name
--------------------------
1 , 1, foo
2 , 1, bar
key 1 and 2 are forming the primary key of the table.
Caching turned off:
I ask for (1,1) -> I get (1,1,foo)
I ask for (2,1) -> I get (2,1,bar)
Same with caching turned on (everything else unchanged)
I ask for (1,1) -> I get (1,1,foo)
I ask for (2,1) -> I get (1,1,foo)
Details below:
The test snippet:
.....SNIP
PersistenceBroker pb =
PersistenceBrokerFactory.defaultPersistenceBroker();
for (int key1 = 0; key1 < 1000; key1++) {
for (int key2 = 90000; key2 < 100000; key2 ++) {
// I have queired by identity, etc, but always got the same result.
String query = new String ("Select * from Testtable where key1
=" + key1 +" and key2= " + key2 + "");
Query q2 = QueryFactory.newQuery(Histrate.class, query);
Iterator it = pb.getIteratorByQuery(q2);
try {
Testtable tt (Testtable) (it.next());
// This should never happen.
if ( (key1 != (int)(tt.getKey1())) || (key2 !=
(int)(tt.getKey2()) ) ) {
logger.warning("*** EEEEEEEEEEHHHHHH: "+key1+" =
"+tt.getKey1() + ", " + key2 + " = "+ tt.getKey2());
}
} catch (Exception e){
//
}
}
}
logger.info("ended");
.... SNIP
if I use the non-chacheing version of the Persistance Broker,
( in OJB.properties:
# this works
ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl
)
I get no EEEEEEEEHHHHH messages like
*** EEEEEEEEEEHHHHHH ...
but if I use the standard version,:
# this fails because of cache problems
ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
I get Thousands of EEEEHHH messages like this one:
*** EEEEEEEEEEHHHHHH 6 = 7, 98037=98000
it looks like the cache is delivering an old key pair.
The table class looks like
<class-descriptor
class="ojb.tables.Testtable"
table="Testtable"
>
<field-descriptor id="1"
name="key1"
column="key1"
jdbc-type="INTEGER"
primarykey="true"
/>
<field-descriptor id="2"
name="key2"
column="key2"
jdbc-type="INTEGER"
primarykey="true"
/>
.....
Has any kind soul a hint for me - what did I do wrong? I spent a long
time debugging that problem, but did not succeed.
Kind regards,
Ernst
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Cache errors?
Posted by Ilkka Priha <im...@surfeu.fi>.
Hi Ernst,
OJB version 1.0.1 has a bug in hash codes of ObjectCacheDefaultImpl making it
act like you noticed. Try some other cache implementation, version 1.0 or 1.0.2
pre from cvs.
-- Ilkka
Ernst Temp wrote:
> Hello,
> I am using OJB in my application (Mysql 4.1, Java 1.4.1, Mac OS X)
> mainly as DB access layer. I am using the persistence broker, and had
> strange behavior of the cache. It delivered table entries that were not
> what i queried for.
>
> Assume a table contents like
> Key1 , key2 , name
> --------------------------
> 1 , 1, foo
> 2 , 1, bar
> key 1 and 2 are forming the primary key of the table.
>
> Caching turned off:
> I ask for (1,1) -> I get (1,1,foo)
> I ask for (2,1) -> I get (2,1,bar)
>
> Same with caching turned on (everything else unchanged)
> I ask for (1,1) -> I get (1,1,foo)
> I ask for (2,1) -> I get (1,1,foo)
>
> Details below:
>
> The test snippet:
> .....SNIP
> PersistenceBroker pb =
> PersistenceBrokerFactory.defaultPersistenceBroker();
>
> for (int key1 = 0; key1 < 1000; key1++) {
> for (int key2 = 90000; key2 < 100000; key2 ++) {
> // I have queired by identity, etc, but always got the same
> result.
> String query = new String ("Select * from Testtable
> where key1 =" + key1 +" and key2= " + key2 + "");
> Query q2 = QueryFactory.newQuery(Histrate.class, query);
> Iterator it = pb.getIteratorByQuery(q2);
> try {
> Testtable tt (Testtable) (it.next());
> // This should never happen.
> if ( (key1 != (int)(tt.getKey1())) || (key2 !=
> (int)(tt.getKey2()) ) ) {
> logger.warning("*** EEEEEEEEEEHHHHHH: "+key1+"
> = "+tt.getKey1() + ", " + key2 + " = "+ tt.getKey2());
> }
> } catch (Exception e){
> //
> }
> }
> }
> logger.info("ended");
>
> .... SNIP
>
> if I use the non-chacheing version of the Persistance Broker,
> ( in OJB.properties:
> # this works
> ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl
> )
> I get no EEEEEEEEHHHHH messages like
> *** EEEEEEEEEEHHHHHH ...
>
>
> but if I use the standard version,:
> # this fails because of cache problems
> ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
>
> I get Thousands of EEEEHHH messages like this one:
> *** EEEEEEEEEEHHHHHH 6 = 7, 98037=98000
> it looks like the cache is delivering an old key pair.
>
> The table class looks like
>
> <class-descriptor
> class="ojb.tables.Testtable"
> table="Testtable"
> >
> <field-descriptor id="1"
> name="key1"
> column="key1"
> jdbc-type="INTEGER"
> primarykey="true"
> />
> <field-descriptor id="2"
> name="key2"
> column="key2"
> jdbc-type="INTEGER"
> primarykey="true"
> />
> .....
>
> Has any kind soul a hint for me - what did I do wrong? I spent a long
> time debugging that problem, but did not succeed.
>
> Kind regards,
> Ernst
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
> .
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org