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

Nullable annotations used for non-null returning Specification methods [DATAJPA-1622] #1880

spring-projects-issues opened this issue Nov 4, 2019 · 2 comments


Copy link

@spring-projects-issues spring-projects-issues commented Nov 4, 2019

Nicholas Tsim opened DATAJPA-1622 and commented

I'm currently using Specifications to help construct my queries and have been trying to upgrade to Spring Boot 2.2 (and consequently Spring Data JPA 2.2). Importantly, I am using Kotlin and this upgrade is a little trickier than I would have liked due to new @Nullable annotations that have been attached to method return types in Specification.

As a result of these new annotations, I am now experiencing compiler errors as Kotlin is (rightly) asserting that I should be treating the returned types as nullable.

Having looked at the Specification code, it seems that these methods are always returning non-null Specification lambdas, which contradicts the use of @Nullable annotations.

I'm not entirely sure if this was intentional or not, but this change does not feel very ergonomic, particularly if you are using Kotlin. It seems like my current solutions are to create non-null variants of the existing methods or use clunky type assertions everywhere. Ideally, the @Nullable return type annotations would be completely removed to make working with Kotlin easier

Affects: 2.2 GA (Moore)

Issue Links:

  • DATAJPA-1744 Possibly wrong annotations
    ("is duplicated by")

  • DATAJPA-1766 Remove invalid @Nullable from Specification
    ("is duplicated by")

  • DATAJPA-1650 SpecificationComposition.composed is annotated with @Nullable
    ("is duplicated by")

  • DATAJPA-1612 Revised nullability enforcement in Querydsl too high for findAll methods

  • DATAJPA-1651 Collection/varargs utility methods for composing Specifications

Referenced from: pull request #397, and commits 84f4b71, 74644e7, 55ae8e6

Backported to: 2.3.5 (Neumann SR5)

1 votes, 4 watchers

Copy link

@spring-projects-issues spring-projects-issues commented Nov 6, 2019

Jens Schauder commented

A somewhat related issue.
While we are using to many @Nullable annotations with Specification we might be to strict with Querydsl predicates

Copy link

@spring-projects-issues spring-projects-issues commented Nov 7, 2019

Mark Paluch commented

Let's discuss whether we can get rid of nullability entirely and make Specification a truly non-nullable API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.