perplexhub / rsql-jpa-specification

Java Library to Translate RSQL into Spring Data JPA Specification and QueryDSL Predicate
MIT License
233 stars 63 forks source link

Support Spring Boot 3 #62

Closed manosbatsis closed 1 year ago

manosbatsis commented 2 years ago

See this section in Preparing for Spring Boot 3.0.

Main issue should be the use of Jakarta EE 9 APIs (jakarta.) instead of EE 8 (javax.), e.g. javax.persistence.EntityManager should be jakarta.persistence.EntityManager.

Tried Spring Boot 3.0.0-M3 with the current release and it fails to launch with

java.lang.AbstractMethodError: Receiver class io.github.perplexhub.rsql.RSQLJPASupport$1 does not define or inherit an implementation of the resolved method 'abstract jakarta.persistence.criteria.Predicate toPredicate(jakarta.persistence.criteria.Root, jakarta.persistence.criteria.CriteriaQuery, jakarta.persistence.criteria.CriteriaBuilder)' of interface org.springframework.data.jpa.domain.Specification.
perplexhub commented 1 year ago

V6.0.2

luisalves00 commented 1 year ago

I'm getting:

Caused by: java.lang.IllegalStateException: No entity manager bean found in application context
    at io.github.perplexhub.rsql.RSQLVisitorBase.getManagedType(RSQLVisitorBase.java:186) ~[rsql-common-6.0.2.jar:?]
    at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.findPropertyPath(RSQLJPAPredicateConverter.java:61) ~[rsql-jpa-6.0.2.jar:?]
    at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.visit(RSQLJPAPredicateConverter.java:188) ~[rsql-jpa-6.0.2.jar:?]
    at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.visit(RSQLJPAPredicateConverter.java:25) ~[rsql-jpa-6.0.2.jar:?]

Do I need to do some extra configuration?

perplexhub commented 1 year ago

Are you using the starter dependency?

perplexhub commented 1 year ago

Does it help? https://github.com/perplexhub/rsql-jpa-specification/blob/master/rsql-jpa/src/test/java/io/github/perplexhub/rsql/Application.java

luisalves00 commented 1 year ago

wow...that's was fast

image

I think is the auto configuration that is not kicking in.

on spring boot 3 you need to define it like:

image

so a filie like this: META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

and the file content is just: io.github.perplexhub.rsql.RSQLJPAAutoConfiguration

perplexhub commented 1 year ago

Thanks for pointing out. Would you mind to create a PR to fix it? Thanks.

luisalves00 commented 1 year ago

Thanks. You're proposal will work I guess...as I said is only the auto configuration that isn't working. Did the PR, just waiting for approval.

alierdogan7 commented 10 months ago

Does it help? https://github.com/perplexhub/rsql-jpa-specification/blob/master/rsql-jpa/src/test/java/io/github/perplexhub/rsql/Application.java

I ran into the same issue which caused No entity manager bean found in application context and the solution was adding @EnableJpaRepositories(basePackages = { "io.github.perplexhub.rsql" }}) annotation as shown in Application.java. Thanks for this great work! @perplexhub

By the way, this configuration was not mentioned in README file. Could you add this requirement for others to be aware of that config? @perplexhub

perplexhub commented 10 months ago

Updated. Thanks.