Last active
August 29, 2015 14:00
-
-
Save kknd22/43087a31701ed68fb3ab to your computer and use it in GitHub Desktop.
register for hibernate proxy gson factory adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* in grails-app/resource/spring/resource.groovy | |
* beans = { | |
* hibernateProxyAdapterFactory(hbadapter.HibernateProxyAdapterFactory) | |
* } | |
* | |
*/ | |
package hbadapter; | |
import org.hibernate.proxy.HibernateProxy; | |
import com.google.gson.Gson; | |
import com.google.gson.TypeAdapter; | |
import com.google.gson.TypeAdapterFactory; | |
import com.google.gson.reflect.TypeToken; | |
public class HibernateProxyAdapterFactory implements TypeAdapterFactory { | |
public TypeAdapter create(Gson gson, TypeToken type) { | |
return (HibernateProxy.class.isAssignableFrom(type.getRawType()) ? new HibernateProxyTypeAdapter(gson) : null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment