Skip to content

Query methods with dynamic projections which return Optional, Stream or Page throw NoSuchElementException [DATAJPA-1185] #1520

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 Sep 22, 2017 · 7 comments
Assignees
Labels
in: core Issues in core support type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link

Sergei Poznanski opened DATAJPA-1185 and commented

Query methods with dynamic projections, which return Optional, Stream or Page, throw NoSuchElementException

For example:

public interface CommentRepo extends JpaRepository<Comment, Integer> {
	// doesn't work - throw NoSuchElementException
	<T> Optional<T> findByUserName(String name, Class<T> type);
	<T> Page<T> getAllByTextLike(Pageable pageable, String text, Class<T> type);
        <T> Stream<T> findStreamByTextLike(String text, Class<T> type);
}

Project example and tests

P.S. Also the documentation has an error in the Dynamic projections topic - the repo method must start with type parameter:

interface PersonRepository extends Repository<Person, UUID> {

   <T> Collection<T> findByLastname(String lastname, Class<T> type);
}

Affects: 1.11.7 (Ingalls SR7)

Reference URL: https://github.com/Cepr0/sd-jpa-projections/blob/master/src/main/java/io/github/cepr0/projections/repo/CommentRepo.java

Issue Links:

  • DATACMNS-1177 Parameter.isDynamicProjectionParameter() does not handle wrapper types properly
    ("depends on")

Referenced from: pull request #223

Backported to: 1.11.9 (Ingalls SR9)

1 votes, 5 watchers

@spring-projects-issues
Copy link
Author

Marcel Overdijk commented

This PR (spring-projects/spring-data-examples#295) provides a failing test caused by this issue

@spring-projects-issues
Copy link
Author

Marcel Overdijk commented

Is this something considered for 2.0 (Kay) release?

@spring-projects-issues
Copy link
Author

Jens Schauder commented

That's the current plan and we'll have a backport as well

@spring-projects-issues
Copy link
Author

Marcel Overdijk commented

OK great to hear!

@spring-projects-issues
Copy link
Author

Jens Schauder commented

PR for backport #222

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

The backport branch doesn't rebase cleanly onto current 1.12.x, would you mind resolving that? I'll push the merge for master in the meantime

@spring-projects-issues
Copy link
Author

Jens Schauder commented

Wasn't sure if you were done with the existing branch, therefore created a new one:

https://github.com/spring-projects/spring-data-jpa/tree/issue/1.12.x/DATAJPA-1185

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: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants