1st level cache and query statistics?

2 Messages Forum Options Options
Permalink
graffer
1st level cache and query statistics?
Reply Threaded More
Print post
Permalink
Hello guys,

My environment: JBOSS 4.2.1, OpenJPA 1.1, Java 5, EJB 3 (+JPA), build time enhancement, many entities

I currently try to get some statistics of the entity manger usage. JPA provides no standardized way to find out how many entities are in the 1st level cache. I only know it from Hibernate, it has a Session.getStatistics() which returns basic information about the current session. More detailed information is available on the SessionFactoy.

So now my question: Is there a similar way in OpenJPA? I would need the following statistics:

1) EntityManager: how many entities (and collections) are in 1st level cache?
2) EntityManagerFactory: how many select / insert / update statements were executed within that SessionFactory?

If those informations are not available via API, how can I access them? Is the 1st level cache in org.apache.openjpa.kernel.Broker?

Thank you for your help.

bye, Georg
Pinaki Poddar
Re: 1st level cache and query statistics?
Reply Threaded More
Print post
Permalink
Hi,

> 1) EntityManager: how many entities (and collections) are in 1st level cache?
OpenJPAEntityManager.getManagedObjects();

> 2) EntityManagerFactory: how many select / insert / update statements were executed within that SessionFactory?
You can attach a JDBCListener [1] (there is an abstract implementation available)

[1] http://openjpa.apache.org/docs/latest/javadoc/org/apache/openjpa/lib/jdbc/JDBCListener.html