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 Kevin Viet <vi...@activia.net> on 2002/12/20 10:58:31 UTC

Help with ODMG

Hello all, I've got a really strange problem with the ODMG API, I hope
someone could help me find the solution ... 


I try this code with my database, 

/*************************************
Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();
db.open("repository.xml", Database.OPEN_READ_WRITE);

OQLQuery query = odmg.newOQLQuery();
query.create("select no from "  + NetworkOperator.class.getName() + "
where name=operator");

// search first object
System.out.println("SEARCH OBJECT 1");
Transaction tx = odmg.newTransaction();
tx.begin();
DList op =  (DList) query.execute();
tx.commit();

// search sd object
System.out.println("SEARCH OBJECT 2 ");
Transaction tx2 = odmg.newTransaction();
tx2.begin();
DList op2 = (DList) query.execute();
tx2.commit();
/***************************************

I printed out the hashtable contents of ojb cache when an object is
looked up in the cache

[junit] SEARCH OBJECT 1
[junit] [org.apache.ojb.broker.accesslayer.JdbcAccess] DEBUG:
executeQuery : Query from class bean.biz.NetworkOperator where
org.apache.ojb.broker.query.Criteria@1462851
junit] [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl]
DEBUG: SQL: SELECT A0.name,A0.logserver FROM operator A0
junit][org.apache.ojb.broker.accesslayer.AbstractPoolableConnectionFactory]
junit] HASHTABLE : {}		<- empty : normal

//
// .... plenty of ojb line debug ...
//

junit] HASHTABLE 		<- full ob object : normal
{net.activia.biz.NetworkOperator{operator}=java.lang.ref.SoftReference@c1f10e, bean.biz.User{contact1}=java.lang.ref.SoftReference@1d332b, bean.biz.User{operator}=java.lang.ref.SoftReference@513cf0, bean.biz.User{contact2}=java.lang.ref.SoftReference@b76fa, bean.biz.User{contact3}=java.lang.ref.SoftReference@b01d43}


At the end of the first object query, the hashtable is full of objects
but when the second query is executed the hashtable is empty


[junit] SEARCH OBJECT 2 
[junit] [org.apache.ojb.broker.accesslayer.JdbcAccess] DEBUG:
executeQuery : Query from class
net.activia.cmanager.web.bean.biz.NetworkOperator where
org.apache.ojb.broker.query.Criteria@1462851
junit] [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl]
DEBUG: SQL: SELECT A0.name,A0.logserver FROM operator A0
[junit] HASHTABLE : {}	<- empty : not normal !!!!


The weird thing is when I remove the transactions code I obtain the
result expected, the cache is not empty when the second query is
executed, so does the transaction code empty the cache at commit ?



 

-- 
Kevin Viet <vi...@activia.net>
ActiVia Networks