Log that shows actual SQL query hibernate is executing?

Is there a log file that tells you the actual query hibernate is executing? We have a queryEntity that is behaving strangely and I want to run the same query on the DB to try to isolate the problem.

 

Thanks in advance!

Larson

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    larsont i agree with sikhivahans , by following those steps mention in Link, can enable you to capture the actual query which gets prepared internally by Hibernate/JPA into logs, but however you will not be able to capture the data which will be forwarded for that Query Placeholders as it's Parameter.

    As we know that Hibernate/JPA generally uses PreparedStatement and making the use of placeholders(i.e. ?) and keep on sending the data to this query dynamically, so the log will capture the complete Query but without having Placeholder Data due to security purposes.

    e.g: select col1, col2, col3 from table where condition1=? and condition2=?;

    Generally in Hibernate, if you understand the risk, and still want to see the actual data along with the formed query (which you can directly copy from log and execute into DB without adding the data to the Query manually) then you can use P6Spy API which can capture the Actual query with it's data as well as the number of commits happened for a particular query (if applicable), but this requires as additional configuration, i am not sure do we have any way to configure Hibernate/JPA xml file which Appian uses internally, if yes, then for sure you will be able to capture each and every Query with it's data followed by it's commit statement.

Reply
  • 0
    Certified Lead Developer

    larsont i agree with sikhivahans , by following those steps mention in Link, can enable you to capture the actual query which gets prepared internally by Hibernate/JPA into logs, but however you will not be able to capture the data which will be forwarded for that Query Placeholders as it's Parameter.

    As we know that Hibernate/JPA generally uses PreparedStatement and making the use of placeholders(i.e. ?) and keep on sending the data to this query dynamically, so the log will capture the complete Query but without having Placeholder Data due to security purposes.

    e.g: select col1, col2, col3 from table where condition1=? and condition2=?;

    Generally in Hibernate, if you understand the risk, and still want to see the actual data along with the formed query (which you can directly copy from log and execute into DB without adding the data to the Query manually) then you can use P6Spy API which can capture the Actual query with it's data as well as the number of commits happened for a particular query (if applicable), but this requires as additional configuration, i am not sure do we have any way to configure Hibernate/JPA xml file which Appian uses internally, if yes, then for sure you will be able to capture each and every Query with it's data followed by it's commit statement.

Children
No Data