Hibernate lazy-load application design

前端 未结 3 823
闹比i
闹比i 2020-12-12 10:14

I tend to use Hibernate in combination with Spring framework and it\'s declarative transaction demarcation capabilities (e.g., @Transactional).

As we all known, hib

3条回答
  •  执笔经年
    2020-12-12 10:24

    As we all known, hibernate tries to be as non-invasive and as transparent as possible

    I would say the initial assumption is wrong. Transaparent persistence is a myth, since application always should take care of entity lifecycle and of size of object graph being loaded.

    Note that Hibernate can't read thoughts, therefore if you know that you need a particular set of dependencies for a particular operation, you need to express your intentions to Hibernate somehow.

    From this point of view, solutions that express these intentions explicitly (namely, 2, 4 and 7) look reasonable and don't suffer from the lack of transparency.

提交回复
热议问题