Class HibernateProxySerializer
- java.lang.Object
-
- com.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>
-
- com.fasterxml.jackson.datatype.hibernate4.HibernateProxySerializer
-
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable,com.fasterxml.jackson.databind.ser.ContextualSerializer
public class HibernateProxySerializer extends com.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy> implements com.fasterxml.jackson.databind.ser.ContextualSerializerSerializer to use for values proxied usingHibernateProxy.TODO: should try to make this work more like Jackson
BeanPropertyWriter, possibly sub-classing it -- it handles much of functionality we need, and has access to more information than value serializers (like this one) have.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classHibernateProxySerializer.ProxyReaderInspects a Hibernate proxy to try and determine the name of the identifier property (Hibernate proxies know the getter of the identifier property because it receives special treatment in the invocation handler).
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap_dynamicSerializersFor efficient serializer lookup, let's use this; most of the time, there's just one type and one serializer.protected boolean_forceLazyLoadingprotected org.hibernate.engine.spi.Mapping_mappingprotected boolean_nullMissingEntitiesprotected com.fasterxml.jackson.databind.BeanProperty_propertyProperty that has proxy value to handleprotected boolean_serializeIdentifierprotected com.fasterxml.jackson.databind.util.NameTransformer_unwrapperprotected boolean_wrappedIdentifier
-
Constructor Summary
Constructors Modifier Constructor Description HibernateProxySerializer(boolean forceLazyLoading)Deprecated.HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier)Deprecated.HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, org.hibernate.engine.spi.Mapping mapping)HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, org.hibernate.engine.spi.Mapping mapping, com.fasterxml.jackson.databind.BeanProperty property, com.fasterxml.jackson.databind.util.NameTransformer unwrapper)HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, org.hibernate.engine.spi.Mapping mapping)Deprecated.HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, org.hibernate.engine.spi.Mapping mapping, com.fasterxml.jackson.databind.BeanProperty property)Deprecated.HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, org.hibernate.engine.spi.Mapping mapping)Deprecated.protectedHibernateProxySerializer(HibernateProxySerializer base, com.fasterxml.jackson.databind.BeanProperty property, com.fasterxml.jackson.databind.util.NameTransformer unwrapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacceptJsonFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper visitor, com.fasterxml.jackson.databind.JavaType typeHint)com.fasterxml.jackson.databind.JsonSerializer<?>createContextual(com.fasterxml.jackson.databind.SerializerProvider prov, com.fasterxml.jackson.databind.BeanProperty property)protected ObjectfindProxied(org.hibernate.proxy.HibernateProxy proxy)Helper method for finding value being proxied, if it is available or if it is to be forced to be loaded.protected com.fasterxml.jackson.databind.JsonSerializer<Object>findSerializer(com.fasterxml.jackson.databind.SerializerProvider provider, Object value)booleanisEmpty(com.fasterxml.jackson.databind.SerializerProvider provider, org.hibernate.proxy.HibernateProxy value)booleanisUnwrappingSerializer()voidserialize(org.hibernate.proxy.HibernateProxy value, com.fasterxml.jackson.core.JsonGenerator jgen, com.fasterxml.jackson.databind.SerializerProvider provider)voidserializeWithType(org.hibernate.proxy.HibernateProxy value, com.fasterxml.jackson.core.JsonGenerator jgen, com.fasterxml.jackson.databind.SerializerProvider provider, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer)com.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>unwrappingSerializer(com.fasterxml.jackson.databind.util.NameTransformer unwrapper)
-
-
-
Field Detail
-
_property
protected final com.fasterxml.jackson.databind.BeanProperty _property
Property that has proxy value to handle
-
_forceLazyLoading
protected final boolean _forceLazyLoading
-
_serializeIdentifier
protected final boolean _serializeIdentifier
-
_nullMissingEntities
protected final boolean _nullMissingEntities
-
_wrappedIdentifier
protected final boolean _wrappedIdentifier
-
_mapping
protected final org.hibernate.engine.spi.Mapping _mapping
-
_unwrapper
protected final com.fasterxml.jackson.databind.util.NameTransformer _unwrapper
-
_dynamicSerializers
protected com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap _dynamicSerializers
For efficient serializer lookup, let's use this; most of the time, there's just one type and one serializer.
-
-
Constructor Detail
-
HibernateProxySerializer
@Deprecated public HibernateProxySerializer(boolean forceLazyLoading)
Deprecated.
-
HibernateProxySerializer
@Deprecated public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier)
Deprecated.
-
HibernateProxySerializer
@Deprecated public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, org.hibernate.engine.spi.Mapping mapping)
Deprecated.
-
HibernateProxySerializer
@Deprecated public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, org.hibernate.engine.spi.Mapping mapping)
Deprecated.
-
HibernateProxySerializer
@Deprecated public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, org.hibernate.engine.spi.Mapping mapping, com.fasterxml.jackson.databind.BeanProperty property)
Deprecated.
-
HibernateProxySerializer
public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, org.hibernate.engine.spi.Mapping mapping)- Since:
- 2.12
-
HibernateProxySerializer
public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, org.hibernate.engine.spi.Mapping mapping, com.fasterxml.jackson.databind.BeanProperty property, com.fasterxml.jackson.databind.util.NameTransformer unwrapper)- Since:
- 2.12
-
HibernateProxySerializer
protected HibernateProxySerializer(HibernateProxySerializer base, com.fasterxml.jackson.databind.BeanProperty property, com.fasterxml.jackson.databind.util.NameTransformer unwrapper)
- Since:
- 2.12
-
-
Method Detail
-
createContextual
public com.fasterxml.jackson.databind.JsonSerializer<?> createContextual(com.fasterxml.jackson.databind.SerializerProvider prov, com.fasterxml.jackson.databind.BeanProperty property)- Specified by:
createContextualin interfacecom.fasterxml.jackson.databind.ser.ContextualSerializer
-
unwrappingSerializer
public com.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy> unwrappingSerializer(com.fasterxml.jackson.databind.util.NameTransformer unwrapper)
- Overrides:
unwrappingSerializerin classcom.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>
-
isUnwrappingSerializer
public boolean isUnwrappingSerializer()
- Overrides:
isUnwrappingSerializerin classcom.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>
-
isEmpty
public boolean isEmpty(com.fasterxml.jackson.databind.SerializerProvider provider, org.hibernate.proxy.HibernateProxy value)- Overrides:
isEmptyin classcom.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>
-
serialize
public void serialize(org.hibernate.proxy.HibernateProxy value, com.fasterxml.jackson.core.JsonGenerator jgen, com.fasterxml.jackson.databind.SerializerProvider provider) throws IOException- Specified by:
serializein classcom.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>- Throws:
IOException
-
serializeWithType
public void serializeWithType(org.hibernate.proxy.HibernateProxy value, com.fasterxml.jackson.core.JsonGenerator jgen, com.fasterxml.jackson.databind.SerializerProvider provider, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer) throws IOException- Overrides:
serializeWithTypein classcom.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>- Throws:
IOException
-
acceptJsonFormatVisitor
public void acceptJsonFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper visitor, com.fasterxml.jackson.databind.JavaType typeHint) throws com.fasterxml.jackson.databind.JsonMappingException- Specified by:
acceptJsonFormatVisitorin interfacecom.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable- Overrides:
acceptJsonFormatVisitorin classcom.fasterxml.jackson.databind.JsonSerializer<org.hibernate.proxy.HibernateProxy>- Throws:
com.fasterxml.jackson.databind.JsonMappingException
-
findSerializer
protected com.fasterxml.jackson.databind.JsonSerializer<Object> findSerializer(com.fasterxml.jackson.databind.SerializerProvider provider, Object value) throws IOException
- Throws:
IOException
-
findProxied
protected Object findProxied(org.hibernate.proxy.HibernateProxy proxy)
Helper method for finding value being proxied, if it is available or if it is to be forced to be loaded.
-
-