Attila Sasvari created OOZIE-3076:
-------------------------------------

             Summary: Allow logging OpenJPA SQL queries for debugging
                 Key: OOZIE-3076
                 URL: https://issues.apache.org/jira/browse/OOZIE-3076
             Project: Oozie
          Issue Type: Improvement
            Reporter: Attila Sasvari


If you are curious about the exact SQL that OpenJPA issues to the datastore, 
you can set the following in {{persistence.xml}} in the {{oozie-core jar}}
{code}
<property name="openjpa.Log" value="SQL=TRACE"/>
<property name="openjpa.ConnectionFactoryProperties"/>
{code}
( more info 
https://openjpa.apache.org/builds/2.4.0/apache-openjpa/docs/ref_guide_logging.html
 )

To have effect on OpenJPA logging, you need to update oozie core jar and 
restart oozie.   

Under the hood, {{org.apache.openjpa.conf.OpenJPAConfigurationImpl}} handles 
[this 
part|https://github.com/apache/openjpa/blob/49c1478cf3f107d9f7069bf2102d8cf0b6ca2b12/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java#L393].
 From Oozie, it is called from the {{JPAService}}'s {{init()}} method when [the 
factory 
|https://github.com/apache/oozie/blob/7bda357849e1006f2cc6df58320f8905da2bd3b8/core/src/main/java/org/apache/oozie/service/JPAService.java#L230]
 is created:
{code}
factory = Persistence.createEntityManagerFactory(persistentUnit, props);
{code} 

It shall be possible to control OpenJPA logging programatically via. A 
hard-coded example:
{code}
((EntityManagerFactoryImpl) 
factory).getBrokerFactory().getConfiguration().setLog("SQL=TRACE")
((EntityManagerFactoryImpl) 
factory).getBrokerFactory().getConfiguration().setConnectionFactoryProperties("PrintParameters=true")
{code}
After this openjpa related information will appear in the Oozie logs:
{code}
132816  oozie-derby  TRACE  [Scheduler-8] openjpa.jdbc.SQL - <t 211361417, conn 
1310049886> executing prepstmnt 1558515073 SELECT t0.id, t0.job_id, t0.status, 
t0.external_id, t0.push_missing_dependencies FROM COORD_ACTIONS t0 WHERE 
((t0.status = ? OR t0.status = ?) AND t0.last_modified_time <= ?) 
[params=(String) WAITING, (String) SUBMITTED, (Timestamp) 2017-10-03 
17:02:16.986]
132816  oozie-derby  TRACE  [Scheduler-8] openjpa.jdbc.SQL - <t 211361417, conn 
1310049886> [0 ms] spent
{code}
- To make it easily configurable, a new element should be added to 
{{oozie-default.xml}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to