|
|
|
|
|
by twic
2066 days ago
|
|
That's not Hibernate, that's Spring Data or some such, which is indeed cursed. This bit of Spring was absolutely designed by and for people with no critical thinking ability. Meanwhile, JPA, the standard which Hibernate implements, has a textual query language [1] which is basically SQL but a little more objecty. For example, you can express joins through properties concisely: SELECT c.capital.name FROM Country AS c WHERE c.name = :name
And use constructor expressions [2] to map results into Java objects: SELECT NEW example.CountryAndCapital(c.name, c.capital.name)
FROM Country AS c
[1] https://www.objectdb.com/java/jpa/query/jpql/structure[2] https://www.objectdb.com/java/jpa/query/jpql/select#Result_C... |
|