Glassfish 2.1 never reuses statements with Postgresql and Eclipselink?
We are using Glassfish server 2.1 with Eclipselink JPA 2.1 and connect to a PostgreSQL database 8.4.8. The problem is that in the log file of Postgres I always see a prepare of the statements that were created with em.createQuery or em.createNamedQuery. It seems that no statement that has been prepared is reused. Therefore the performance is really bad.
I tri开发者_如何学Ced setting the default JDBC setting prepareThreshold from 5 to 1. That only changed that the unnamed statements were now named. But they were still not reused.
I also tried several settings for the connection pooling as prepared statements are connection dependent but returned to the default org.postgresql.ds.PGSimpleDataSource and javax.sql.DataSouce.
I enabled statement caching also in the persistence.xml:
<property name="eclipselink.jdbc.cache-statements" value="true"/>
Does Glassfish 2.1 support statement caching? And if it does what are the settings I missed?
Any hints appreciated.
Considering this: http://www.youtube.com/watch?v=hfx_M0p0KoM it seems that 2.1 does not support statement caching.
For completeness:
Here is the link to the statement caching setting in GlassFish 3.1: http://download.oracle.com/docs/cd/E18930_01/html/821-2418/giyck.html#giyci
Here is a developer blog entry explaining the new feature in detail: http://blogs.oracle.com/technical/entry/statement_caching_in_glassfish_v3
精彩评论