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

Add support for searching by Specification and Sort [DATAJPA-48] #484

Closed
spring-projects-issues opened this issue Apr 9, 2011 · 6 comments
Assignees
Labels
in: core Issues in core support type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link

Stevo Slavić opened DATAJPA-48 and commented

JpaSpecificationExecutor public API has support for various combination of Specification, Sort, and Pageable. One is missing tho, findAll(Specification<T>, Sort). private TypedQuery<T> getQuery(Specification<T> spec, Sort sort) in JpaSpecificationExecutor already has everything to support exposing such API.

Attached patch [^DATAJPA-Adds-support-for-finding-by-spec-and-sort.patch] adds List<T> findAll(Specification<T> spec, Sort sort); to JpaSpecificationExecutor interface, appropriate implementation in SimpleJpaRepository and a test case.

Patch also configures project pom to add generated test source directory as maven test source directory using build-helper-maven-plugin. With this and m2eclipse configured to run "process-test-classes" goal on project import or when updating eclipse project configuration, project tests could compile


Affects: 1.0 M2

Reference URL: http://forum.springframework.org/showthread.php?p=356230

Attachments:

Referenced from: commits c4a7114

@spring-projects-issues
Copy link
Author

Stevo Slavić commented

Wish SimpleJpaRepository is more designed for extension. To add workaround until this ticket is resolved, had to duplicate/shadow fields and multiple methods. If only getEntityManager and getQuery methods were protected and not private

@spring-projects-issues
Copy link
Author

Dustin Woods commented

I too would like to see the getQuery method be 'protected' instead of 'private' to apply query hints when using specifications. Should this be a separate issue?

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

I've added the method. What are you exactly meaning with the generated test source directory?

@spring-projects-issues
Copy link
Author

Stevo Slavić commented

Some test sources are generated (using com.mysema.maven:maven-apt-plugin). Only default test source directory is src/test/java. For directory with generated test sources to be compiled and added to test scope classpath, build helper plugin is typically used. Without that ordinary test sources which reference generated test source do not compile.

Btw, some javadoc in SimpleJpaRepository has to be updated to reflect changes when JpaSpecificationExecutor was factored out of JpaRepository. I would have done that but formatting surely wouldn't be correct. SpringSource eclipse formatter used to exist

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

Hi Stevo, have you had a chance to check whether this works for you? The Maven build should just work fine anyway as the APT plugin transparently adds the configured target folder as source folder as well. It builds fine for me on the command line and also does in Eclipse (at least after having done Maven > Update Project configuration in m2eclipse).

@spring-projects-issues
Copy link
Author

Stevo Slavić commented

It works for me too, updating project configuration does the trick. By default m2eclipse doesn't run any goals on Maven project import

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

2 participants