I have a dependency spring-boot-starter-data-jpa
Configuration for JPA is inside application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/db?serverTimezone=UTC spring.datasource.username=name spring.datasource.password=pass ...
When I create @Entity:
@Entity @Table(name="cats") public class Cat { @Column(name="age") private int age; .... }
It works well. When i try to use JPQL:
"select cat from Cat cat"
Intellij idea emphasizes it and says “Can’t resolve symbol Cat”, I click more “This inspection controls whether the Persistence QL Queries are error-checked”.
It’s worth saying it works correctly without errors and exceptions.
To solve it, somebody recommend in Intellij:
Project structure – facets – add – JPA.
After it Intellij stop to show this warning near JPQL syntax, but starts to show warnings near @Column(name=”name”) and @Table(name=”cats”) in my Entity.class.
How to configure JPA not to get this warnings neither in JPQL nor in Entity.class?
Advertisement
Answer
Try using this:
"select cat from " + Cat.class.getName() + " cat"
This solution is quite good, because whenever you rename class Cat
, intellij will rename it inside jpql query as well.