Lazy/Eager loading strategies in remoting cases (JPA)

后端 未结 3 1224
予麋鹿
予麋鹿 2020-12-05 05:47

I\'m running into LazyLoading exceptions like the most people who try remoting with an ORM. In most cases switching to eager fetching solves the problem (Lazy Loading / Non

3条回答
  •  情深已故
    2020-12-05 06:53

    Nowadays (2013), it is possible to keep lazy-loading if you remote your service with GraniteDS.

    That should properly serialize your JPA or Hibernate entities by not initializing lazy relations and keeping the lazy-state for the client. If you access those relations on the client, it will fetch them transparently in the background.

    Moreover, GraniteDS seems to be able to do inverse lazy loading which means that when you send modified objects back to the server, it will not send unchanged entities back thus making the necessary server communication very efficient.

    I am not a GraniteDS expert (yet) but it seems to be able to integrate with JEE6 and Spring service layers and works with all of the most important JPA providers.

    Naturally, you will need to hide the GraniteDS based remoting behind a service interface for maximizing transparent behaviour but that can be easily be done if the client also uses Spring (so you inject the service according to the needs of the environment).

提交回复
热议问题