-----Mensaje original-----
De: Alessandro Colantoni [mailto:[EMAIL PROTECTED] 
Enviado el: jueves, 16 de diciembre de 2004 15:01
Para: 'CLARAMONTE Jean-Baptiste'
Asunto: RE: Cache and PersistenceBroker optimization

So opening a broker, look up for cache and closing the broker shouldn't
affect my performances.

But I'm consuming a lot the Cpu oh the application server, and The DB
server is sleeping 

An other point is that I don't use beginTransaction and commit
transaction because I have just to retrieve data.
Then what about the PersistenceBroker pool?
Can I configure it in some way.
Should it affect my performance if I do a very big use?
thanks

-----Mensaje original-----
De: CLARAMONTE Jean-Baptiste [mailto:[EMAIL PROTECTED] 
Enviado el: jueves, 16 de diciembre de 2004 14:52
Para: 'Alessandro Colantoni '
Asunto: RE: Cache and PersistenceBroker optimization

If I remember well a DB Connection is borrowed when you make a call to
beginTransaction and gets back when you call commitTransaction or
abortTransaction.

PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker() is
borrowing an PersistenceBroker from the PersistenceBroker pool and
broker.close puts it back



-----Message d'origine-----
De: Alessandro Colantoni
A: 'OJB Users List'
Date: 16/12/2004 14:27
Objet: Cache and PersistenceBroker optimization



-----Mensaje original-----
De: Alessandro Colantoni [mailto:[EMAIL PROTECTED] 
Enviado el: jueves, 16 de diciembre de 2004 14:23
Para: 'OJB Users List'
Asunto: Cache and per



Hi all!!
I'm doing a very large use of caching.
I have to do thousands of small queries that look for a small number of
entries.

I'm using the connection pool of OC4J.
The application consumes rapidly a large number of connections.

I implemented the queries in DAOs that have methods like this one

 
public ValueObject findByPrimaryKey(Integer parCodigo)throws
DataAccessException{
        PersistenceBroker broker = null;
        ParametroVO parametroVO = null;
        try{   
            broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();
            parametroVO = new  ParametroVO();
            parametroVO.setParCodigo(parCodigo);
            
            Identity oid = new Identity(parametroVO,broker);
            ObjectCache cache = broker.serviceObjectCache();
            parametroVO = (ParametroVO)cache.lookup(oid);
            if (parametroVO==null){
                Criteria criteria = new Criteria();
                criteria.addEqualTo("parCodigo",parCodigo);
                Query query = new QueryByCriteria(ParametroVO.class,
criteria);
                parametroVO =
(ParametroVO)broker.getObjectByQuery(query);
            }else {
                log.info("************parametroVO in
cache***************");
            }
        } catch (ServiceLocatorException e) {
            log.error("ServiceLocatorException thrown in
ParametroDAO.findByPrimaryKey(Integer parCodigo): " + e.toString());
            throw new DataAccessException("Error in
ParametroDAO.findByPrimaryKey(Integer parCodigo): " + e.toString(),e);
        } catch (ClassNotPersistenceCapableException e) {
            log.error("ClassNotPersistenceCapableException thrown in
ParametroDAO.findByPrimaryKey(Integer parCodigo): " + e.toString());
            throw new DataAccessException("Error in
ParametroDAO.findByPrimaryKey(Integer parCodigo): " + e.toString(),e);
        } finally {
                  if (broker != null) broker.close();
        }
        return parametroVO;
    }

My question is:
The DB connection is opened when I do
broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();

and is released when I do broker.close()?;

As I told, almost always the ValueObject is found in cache.
Is there any way to check if it is in cache without opening a broker?

I saw in documentation the constructor
public Identity(java.lang.Class realClass,
                java.lang.Class topLevel,
                java.lang.Object[] pkValues)

But I don't understand how to use it.
What's the difference between realClass and topLevel?
Does this constructor could be useful for me?

Hoping someone can help me
Thanks in advance 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
*** We scanned this email for malicious content ***
*** IMPORTANT: Do not open attachments from unrecognized senders  ***
*** MailSystem ASTON ***




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to