mons.dbcp.BasicDataSourcequot; destroy-method=quot;closequot;gt;
lt;property name=quot;uclquot; value=quot;jdbc:db2--localhost:50004/arenaquot; /gt;
lt;property name=quot;usernamequot; value=quot;********quot; /gt;
lt;property name=quot;passwordquot; value=quot;********quot; /gt;
lt;property name=quot;driverClassNamequot; value=quot;com.ibm.db2.jcc.DB2Driverquot; /gt;
lt;/beangt;
lt;bean id=quot;jpaTMquot;
class=quot;org..orm.jpa.JpaTransactionM anagerquot;gt;
lt;property name=quot;entityManagerFactoryquot; ref=quot;entityManagerFactoryquot; /gt;
lt;property name=quot;dataSourcequot; ref=quot;dataSourcequot;/gt;
lt;/beangt;
lt;bean id=quot;entityManagerFactoryquot; class=quot;org..orm.jpa.LocalContainerE ntityManagerFactoryBeanquot;gt;
lt;property name=quot;persistenceUnitNamequot; value=quot;arenaquot; /gt; lt;property name=quot;dataSourcequot; ref=quot;dataSourcequot;/gt; lt;property name=quot;persistenceXmlLocationquot; value=quot;META-INF/persistence-container.xmlquot;gt;lt;/propertygt; lt;property name=quot;jpaVendorAdapterquot;gt; lt;bean class=quot;org..orm.jpa.vendor.TopLinkJ paVendorAdapterquot;gt;lt;property name=quot;showSqlquot; value=quot;truequot;/gt; lt;property name=quot;databasePlatformquot; value=quot;oracle.toplink.essentials.platform.database .DB2Platformquot;/gt;lt;/beangt; lt;/propertygt;
lt;/beangt;
lt;/beansgt;
and the corresponding persistence-container.xml
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;persistence version=quot;1.0quot;
xmlns=quot;xml/ns/persistencequot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xsi:schemaLocation=quot;xml/ns/persistence xml/ns/persistence/persistence_1_0.xsdquot;gt;
lt;persistence-unit name=quot;arenaquot; transaction-type=quot;RESOURCE_LOCALquot;gt;
lt;providergt;oracle.toplink.essentials.PersistencePro viderlt;/providergt;
lt;propertiesgt;
lt;property name=quot;toplink.logging.levelquot; value=quot;FINEquot; /gt;
lt;/propertiesgt;
lt;/persistence-unitgt;
lt;/persistencegt;
The container test case was started with -javaagent:lib/spring-agent.jar option of course.
I knew that the cache was not working after monitorig the logs and observing that in the case of local-container test case the runtime issues two selects to the DB:
[TopLink Fine]: 2008.04.14 10:44:14.301--ClientSession(25537913)--Connection(20978984)--Thread(Thread[main,5,main])--SELECT ID, NAME FROM orders WHERE (ID = ?)
bind =gt; [14]
Since this is a simple setup I can provide the whole eclipse jar-ed project.
The commented method testCacheInsert was used to insert some orders into the database. Event stranger is that if only this method is used the runtime does not (in either cases) issues any select statements to the DB. So if one wants to reproduce the problem, run one of the test with testCacheInsert uncommented (or just insert a row into the db ) and after that run the two test cases as they are posted here. ( em.flush(); from the insertOrder method is neccesary for running testCacheInsert method )
Any help would be appreciated.
Regards,
Horia
It seems however that somebody else faces a related problem: forums/thre...95157amp;tstart=0
After further testing it seems that the cause of this is the use of TopLinkJpaVendorAdapter with the LocalContainerEntityManagerFactory because the moment I remove the jpaVendorAdapter property ( probably the EM factory will use the default JpaVendorAdapter ) the cache is used again.
Still, the cache should work right or the cache bypass with the ToplinkJpaVendorAdapter is intentional?
Regards,
Horia
Hi, I'm currently runing apache-tomcat-6.0.26 / spring-framework-3.0.2.RELEASE / TopLink 2.0.0.b41-beta2 and the above stated by 5hao is still true (more then two years past since then):
After further testing it seems that the cause of this is the use of TopLinkJpaVendorAdapter with the LocalContainerEntityManagerFactory because the moment I remove the jpaVendorAdapter property ( probably the EM factory will use the default JpaVendorAdapter ) the cache is used again.
Many thanks 5hao !!!
In order to use this workaround I had to put the following
Code:
lt;providergt;oracle.toplink.essentials.PersistenceProviderlt;/providergt;into my persistence.xml.
So, probably to switch between Hibernate and TopLink one should change two files - persistence.xml and applicationContext.xml instead just one of them - applicationContext.xml.
Please fix.
Thanks in advance,
bodrin |