5608057 / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

Get the invoked JPA query before it converted to SQL #319

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

when using any JPA framework like hibernate, why javamelody can get the SQL 
invoked and can't get the JPA query itself before being translated into SQL. It 
is useful for developers to get the JPA query itself.

What is the expected output? What do you see instead?

What version of the product are you using? On what application server, JDK,
operating system?

Please provide any additional information below.

Original issue reported on code.google.com by Eng.Usam...@gmail.com on 23 Jun 2013 at 11:51

GoogleCodeExporter commented 8 years ago
This is not a bug but an enhancement.
How would you do it for hibernate?

Original comment by evernat@free.fr on 23 Jun 2013 at 2:17

GoogleCodeExporter commented 8 years ago
Sorry for listing it as a bug, you are right it is an enhancement. Currently, 
I'm using openjpa 2.0 and I write named queries above the entities or within 
DAO operation methods and I want to get the real JPA query in addition to its 
translated SQL statement.

Original comment by Eng.Usam...@gmail.com on 24 Jun 2013 at 2:54

GoogleCodeExporter commented 8 years ago
Your comment doesn't say how to be notified about it for hibernate or for 
openjpa, as you wish.
Can you complete this issue?
Thanks.

Original comment by evernat@free.fr on 13 Aug 2013 at 9:46

GoogleCodeExporter commented 8 years ago
I'll assume an example. Imagine we have a method that executes a JPQL named 
query using OpenJPA to retrieve data from the DB "retrieveManagerEmployees". 
Currently, the report generated by Melody can list this method and when 
clicked, it lists the SQL statement executed through it. This SQL statement 
actually is the JPQL after being translated to SQL to be executed over DB. I 
wonder if java melody can capture the original JPQL query before being 
translated to SQL. because sometimes it is very hard to guess the original  JPA 
query from the generated SQL captured by java melody

Original comment by Eng.Usam...@gmail.com on 14 Aug 2013 at 8:35

GoogleCodeExporter commented 8 years ago
I understand. But what java code can be written to be notified just before a 
JPQL query is executed?

Original comment by evernat@free.fr on 14 Aug 2013 at 9:51

GoogleCodeExporter commented 8 years ago
I think you may try intercept the JPA's entity manager methods.

Original comment by Eng.Usam...@gmail.com on 14 Aug 2013 at 2:29

GoogleCodeExporter commented 8 years ago
how?

Original comment by evernat@free.fr on 14 Aug 2013 at 2:44

GoogleCodeExporter commented 8 years ago
Spring, for example, can intercept these calls.

Original comment by Eng.Usam...@gmail.com on 14 Aug 2013 at 2:48

GoogleCodeExporter commented 8 years ago
Do you speak of AOP or something else?
If either case, do you have some documentation or some java class for this?

Original comment by evernat@free.fr on 14 Aug 2013 at 3:03

GoogleCodeExporter commented 8 years ago
I'm talking about a suggested enhancement to java melody to capture the 
original jpa query not only the final sql executed through monitored 
methods.Yes, I suggest using AOP to intercept the entity manager of the JPA 
tool to get the JPA queries if any.

Original comment by Eng.Usam...@gmail.com on 14 Aug 2013 at 5:33

GoogleCodeExporter commented 8 years ago
I don't have a documentation files but I suggest using Spring AOP.

Original comment by Eng.Usam...@gmail.com on 14 Aug 2013 at 5:38

GoogleCodeExporter commented 8 years ago
This is done, JPA queries are monitored when using a persistence.xml file.
See https://code.google.com/p/javamelody/wiki/ReleaseNotes

Original comment by evernat@free.fr on 14 Feb 2014 at 8:46