LDSTechForumProjects

Logging Queries and Query Parameters in JPA/Hibernate

Showing Query Parameters (Work in Progress)

WARNING: THIS INFORMATION MAY NOT BE CORRECT YET

By default, a stack 3 project with JPA is configured to log SQL queries in the "local" profile with the show_sql property on the hibernate configuration in the applicationContext.xml file

<stack-db:hibernate   show_sql-true/>

However, the bind parameters will not be logged. To enable logging of the bind parameters, add org.hibernate.level=TRACE to your local.logging.properties in your deploy project. After a server restart, look for entries in the console that look like this...

[11/08/04 12:16:06:761] 0000000c F1 Printer: org.lds.model.Example{id=9, name=Bruce9, data=asdf}

When hibernate pulls a sequence it reports that too...

[11/08/04 12:16:06:748] 0000000c F1 SQL: 
    select
        SEQ_EXAMPLE_PK.nextval 
    from
        dual
[11/08/04 12:16:06:752] 0000000c F1 SequenceStructure: Sequence value obtained: 9

The following might be helpful additions to your logging.properties as well:

org.hibernate.SQL.level=TRACE
org.hibernate.type.level=TRACE
This page was last modified on 25 March 2014, at 12:15.

Note: Content found in this wiki may not always reflect official Church information. See Terms of Use.