speedment / jpa-streamer

JPAstreamer is a lightweight library for expressing JPA queries as Java Streams
GNU Lesser General Public License v2.1
345 stars 35 forks source link

Cannot generate $ icon files under annotations folder of generated-sources #359

Closed Rapter1990 closed 1 year ago

Rapter1990 commented 1 year ago

I tried to implement an example of Spring Boot with the usage of jpaStreamer. I use Intellij Idea to handle with it. I have a problem in jpaStreamer.stream.

Here are the dependencies shown below

<jpastream.version>1.1.4</jpastream.version>

<dependency>
    <groupId>com.speedment.jpastreamer</groupId>
    <artifactId>jpastreamer-core</artifactId>
    <version>${jpastream.version}</version>
</dependency>

<dependency>
    <groupId>com.speedment.jpastreamer.integration.spring</groupId>
    <artifactId>spring-boot-jpastreamer-autoconfigure</artifactId>
    <version>${jpastream.version}</version>
</dependency>

Here is the sample method of UserService shown below

public List<User> findAllForJpaStreamer() {
   return jpaStreamer.stream(User.class).
          sorted(User$.id).
          collect(Collectors.toList());
}

I get this error message shown below

Cannot resolve symbol 'User$'

Here is the screenshot shown below

enter image description here

enter image description here

How can I fix it?

Here is the repo : Link

julgus commented 1 year ago

I cannot see that you have a User Entity, I only find a Person Entity. JPAStreamer only generates entities from the existing JPA model that you have.

I also note that the Person class is using jakarta.persistence which is part of JPA 3. JPAStreamer version 1.1.4 is only compatible with JPA 2, but if you update jpastreamer.version to 3.0.3 and rebuild your project you should get a Person$ generated in target/generated-sources. Give it a try and let me know how it goes.

julgus commented 1 year ago

Also thanks for providing a complete example application - helps a lot!

Rapter1990 commented 1 year ago

@julgus I solved the issue and I forgot to inform you about that. I implemented a config class to handle with that. Thank you for your answer.

julgus commented 1 year ago

Great, thanks for the update!