As for the JPA to construct a dynamic query?

Hi all.
There is a helloworld project on Spring + Hibernate.
There are three entities: Offer Car and Brand. Described in hbm.xml.
Associated they and Car.brand.
I need to get all the Offer for my
In SQL it looks like this: select * from offers, cars, brands..offers where car_id = and cars.brand_id = and = n;
Want to gash a dynamic build the query if you know only the entities at the ends of the chain. For example, when the chain E1.e2 -> E2.e3 -> . . . -> En.em -> Em known only to E1 and Em and the length of the chain of related entities is not known. Hence the question: is there any ready elegant way to get a list of entities? Or maybe you can just get the ResultSet?
You want to avoid such things as:
1. hardcoding SQL using the annotation @Query.
2. use string constants with the names of the tables.
3. the zapilivanija for each query to a separate method findAll() in the service.
Using JpaSpecificationExecutor.findAll(Specification)), and classes that extends CrudRepository, JpaSpecificationExecutor.
March 23rd 20 at 19:07
2 answers
March 23rd 20 at 19:09
Criteria API.
March 23rd 20 at 19:11
As an option querydsl
Sorry not supported for more than 3 years. But for option thanks . - Stephen62 commented on March 23rd 20 at 19:14

Find more questions by tags SpringHibernateJava