Skip to content

Support for textual annotation of originating repository method in generated (sql) statements [DATAJPA-365] #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 3, 2013 · 1 comment
Assignees
Labels
in: core Issues in core support type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Thomas Darimont opened DATAJPA-365 and commented

When a database administrator observes a performance problem (e.g. a slow query) it is often difficult
to determine which part of an application (e.g. in the context of an java application with spring-data-jpa which repository/method)
is the cause of the issue.

This feature proposes an extension to the sql statement generation mechanism:
Support for textual annotation of originating repository method in a generated sql statement
e.g. in the form of a comment (similar to regular query hints) that states the (simple) class Name of
the originating spring data repository as well the method which resulted in the statement.

This gives the database administrator as well as the application developer a more detailed hint where
to look for the performance problems in the application code.

Things to consider:
The comment mechanisms can be quite database dependent.
This feature is very generic and should actually be implemented at a lower (e.g. within the jpa itself).
May be one could use the jpa query hint facilities.

Here is a short example:

Without "originating repository method":

FooRepository.findBarWhereAttr1AndAttr2(..,..)

->

select 
* 
from foo where attr1, attr2

With "originating repository method":

FooRepository.findBarWhereAttr1AndAttr2(..,..) 

->

select 
/* FooRepository.findBarWhereAttr1AndAttr2 */ 
* from foo where attr1, attr2

No further details from DATAJPA-365

@spring-projects-issues
Copy link
Author

Thomas Darimont commented

Hello,

we could generalize the recently introduced @Meta annotation from Spring Data MongoDB, move it
to SD commons and then use it's "comment" attribute to generate approprirate query hints to inject
the comment into the generated query.

Hibernate:
@QueryHints({ @QueryHint(name = "org.hibernate.comment", value = "test") })

EclipseLink:
@QueryHints({ @QueryHint(name = "eclipselink.sql.hint", value = "test") })

OpenJPA: 
???
{code9}

Cheers,
Thomas

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core support labels Dec 30, 2020
gregturn added a commit that referenced this issue Jul 11, 2022
@gregturn gregturn self-assigned this Jul 11, 2022
@gregturn gregturn added this to the 3.0 M5 (2022.0.0) milestone Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants