Skip to content

Instantly share code, notes, and snippets.

@dipold
Last active August 29, 2015 13:57
Show Gist options
  • Save dipold/9781039 to your computer and use it in GitHub Desktop.
Save dipold/9781039 to your computer and use it in GitHub Desktop.
import java.lang.reflect.Type;
import org.hibernate.proxy.HibernateProxy;
import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public class HibernateProxySerializer implements JsonSerializer<HibernateProxy> {
@Override
public JsonElement serialize(HibernateProxy src, Type typeOfSrc, JsonSerializationContext context) {
Object deProxied = src.getHibernateLazyInitializer().getImplementation();
return context.serialize(deProxied);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment