Filtering lazy-loaded JPA fields in JAX-RS with Jackson
While working on a side project using a JAX-RS API and JPA I wanted to explore how the entity graph
features introduced in JPA 2.1 could be used to simplify data fetches for different endpoints. One
issue I quickly ran into was how to deal with
LazyInitializationExceptions with unloaded lazy
The Hibernate module supplied by Jackson didn’t meet my needs and I couldn’t find any examples of what I needed so it was time to delve into how Jackson filtering works. The end solution turned out to be fairly straightforward and doesn’t rely on any vendor specifics so it’s worth sharing.