Category: Programming

Filtering lazy-loaded JPA fields in JAX-RS with Jackson

29th
Jul
2020

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 fields.

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.

Custom gradient controls for iOS

23rd
Jan
2012

Recently I needed custom UI control for iOS that had rounded corners and a gradient background. To make the user experience as rich as possible I wanted the background of the control to flatten when the user tapped it. There were plenty of examples of gradient buttons and rounded corner views but nothing did exactly what I needed.

After a bit of experimentation I found the easiest solution was to add a gradient layer to a custom UIControl and swap it with a different layer when the control became highlighted.