Skip to content
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

Creation of @NativeQuery annotation for repositories [DATAJPA-117] #543

Closed
spring-projects-issues opened this issue Oct 20, 2011 · 2 comments
Assignees
Labels
in: core type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Oct 20, 2011

Francesco Poli opened DATAJPA-117 and commented

I am currently using spring-data-jpa in a legacy environment and a native jdbc / sql approach is needed to accomplish a number of operations (selects, updates, etc.).

Whenever I can, I use @Query annotation together with entity related repositories, keeping entities clean of process logic. But if I need to create a native query I need to put it into a jpa @NamedNativeQuery annotation into the entity, or to write it down into orm.xml.

IMHO, I think that developing a @NativeQuery annotation, that acts like the @Query one and accepts native sql statements, can improve the separation between the model and the persistence logic, keeping this where it really belongs (into the repository)


Attachments:

Referenced from: commits c134e10

1 votes, 0 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 16, 2011

Oliver Drotbohm commented

That's a great suggestion. Nevertheless I think we rather might end up with a plain native flag on the already existing @Query annotation all the other infrastructure support (potentially providing a custom query to be used for pagination etc.) should be reused and the flip switch between native and JPQL queries essentially boil down to a different method call on the EntityManager

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 2, 2011

Oliver Drotbohm commented

Fixed, should be available in tonights snapshot. Note, that we don't support pagination and dynamic sorting on query methods using native queries as we'd have to manipulate the manually defined query which we cannot do reliably

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants