0

Spring provides the OpenEntityManagerInViewFilter to enable lazy loading of objects during the view phase, but what if I would like to use it in a message passing architecture like STOMP over websockets?

If I need to return an entity that has lazy properties in a @MessageMapping method the only way to do it that I know is to manually invoke property getters on the entity before returning it otherwise Jackson will raise an exception while serializing it to JSON.

Are there any more elegant solutions to that generic problem?

Alessandro Polverini
  • 2,301
  • 19
  • 29
  • You can add '@Tranactional' to your '@MessageMapping' controller method. But I would not call it elegant. Also prob won't work in ListenableFuture style scenarios – Marc Aug 10 '16 at 12:02
  • I'm already using @Transactional, but serialization is done by the framework on another level (like the view for web), so it does not work. – Alessandro Polverini Aug 11 '16 at 08:34

0 Answers0