show_sql output should identify the Named Query associated with generated SQL output
------------------------------------------------------------------------------------
Key: HHH-3289
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3289
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.3.0
Reporter: Jim Doyle
It is useful to know which named query was at cause for generated SQL traffic in output
logs. Medium sized applications can realistically employ a hundred named queries and it
is extremely useful to known the ID of the named query as well as see the generated SQL.
This feature would very much improve the ability of DBAs to undertake performance tuning.
In a typical use case, the DBA would cut and paste the
generated show_sql query directly in the the vendor database Explain tool to analyze
performance. After manually tuning the query in the Explain analyzer,
changes to the JPQL or HQL can then be applied, deployed and tested again by looking at
the generated SQL.
I propose changing the show_sql output to appear as follows:
10:21:04,397 INFO [STDOUT] Hibernate [MYsessionFactoryId] [MYnamedQueryName] : select
top 5 pro0_.transactionID as transact2_27_, pro0_.date as date27_,
pro0_.suffix_suffixCodeID as suffix40_27_, pro0_.creationDate as creation4_27_, ....
A String that identifies the Session Factory will be printed to disambiguate the
originating SF that produced the SQL. This is necessary in environments where
more than one session factory is present (JBoss container, multiply deployed application
in Tomcat). In such cases, it *MIGHT* be possible for two different session factories to
have identically named named queries, so by printing an Id for the Session Factory, there
is a means of resolving this when examing the output.
The Named Query identifier will only appear for Named Native or Named JPQL/HQL type
queries. For ad-hoc queries, the brackets may be either empty
or not present to indicate that the generated SQL verbs originate from a source other than
a named query.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira