There is a helloworld project on Spring + Hibernate.
There are three entities: Offer Car and Brand. Described in hbm.xml.
Associated they Offer.car and Car.brand.
I need to get all the Offer for my Brand.id.
In SQL it looks like this: select * from offers, cars, brands..offers where car_id = cars.id and cars.brand_id = brands.id and brands.id = 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.