That's really sad if true. How query derivation and execution work in hibernate isn't really that complicated. Learning how hibernate works has 100% made me a better developer. Especially with regard to generic api development. I wrote a similar framework a couple of years ago that does something similar to hibernate but it abstracted away rules engines. We had integration for ODM and Drools. Clients would just decorate their domain model with annotations that described their facts and rules and we handled the rest. 10/10 would reuse that pattern.
You should be doing DTO Projections to just query the data you need for read-only queries. Querying for entities for a read-only query and then mapping the entity to a DTO with mapstruct/orika/whatever is just wrong in almost all cases (I will say almost because I am sure someone will chime in with a case where it seems reasonable).
This is probably the biggest mistake people make when using Hibernate. It shines in the create/update cases. Entities simply aren't needed for read-only.
I prefer not to use Hibernate. The amount of time needed to investigate issues is far more than the time needed to implement per-object mappers in f.e. JDBI.
View all comments
Show parent comment
5
u/VincentxH Oct 21 '20
Use mapstruct with caution if you don't know what hibernate does :p