Document directory
- How do I see the SQL that openjpa is executing?
How do I see the SQL that openjpa is executing?
Openjpa provides retriable channel-based logging, as described in the chapter on logging. The simplest example of enabling verbose logging is by using the following property in yourPersistence. xmlFile:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> <persistence-unit name="example-logging" transaction-type="RESOURCE_LOCAL"> <properties> <property name="openjpa.Log" value="SQL=TRACE"/> </properties> </persistence-unit></persistence>
How do I enable Connection pooling in openjpa?
Openjpa doesn' t include any built-in connection pool, but you can use any third-party connection pool that is accessible via the JDBC datasource API (which most are). The followingPersistence. xmlExample shows how to use openjpa with a Apache Derby database and the Apache DBCP connection pool:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> <persistence-unit name="example-derby" transaction-type="RESOURCE_LOCAL"> <properties> <property name="openjpa.ConnectionProperties" value="DriverClassName=org.apache.derby.jdbc.ClientDriver, Url=jdbc:derby://localhost:1527/database, MaxActive=100, MaxWait=10000, TestOnBorrow=true, Username=user, Password=secret"/> <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/> </properties> </persistence-unit></persistence>
See the documentation on using a third-party datasource for further details.