org.hibernate.proxy.HibernateProxy .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.
| Modifier and Type | Class and Description |
|---|---|
| protected static class | Hibernate5JProxySerializer.
Inspects 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). |
| protected static class | Hibernate5JProxySerializer.
Hibernate 5.2 broke abi compatibility of org.hibernate.proxy.LazyInitializer.getSession() The api contract changed from org.hibernate.proxy.LazyInitializer.getSession()Lorg.hibernate.engine.spi.SessionImplementor; to org.hibernate.proxy.LazyInitializer.getSession()Lorg.hibernate.engine.spi.SharedSessionContractImplementor On hibernate 5.2 the interface SessionImplementor extends SharedSessionContractImplementor. |
| Modifier and Type | Field and Description |
|---|---|
| protected PropertySerializerMap | _dynamicSerializers
For efficient serializer lookup, let's use this; most of the time, there's just one type and one serializer. |
| protected final boolean | |
| protected final Mapping | |
| protected final boolean | |
| protected final BeanProperty | _property
Property that has proxy value to handle |
| protected final boolean | |
| protected final NameTransformer | |
| protected final boolean |
| Access | Constructor and Description |
|---|---|
| public | Hibernate5JProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, Mapping mapping)
|
| public | Hibernate5JProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, Mapping mapping, BeanProperty property, NameTransformer unwrapper)
|
| protected | Hibernate5JProxySerializer(Hibernate5JProxySerializer base, BeanProperty property, NameTransformer unwrapper)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType
Type of element (entity like property) being visited typeHint)Overrides com. Implements com. Default implementation simply calls |
| public JsonSerializer | createContextual(SerializerProvider
Serializer provider to use for accessing config, other serializers prov, BeanProperty Method or field that represents the property
(and is used to access value to serialize).
Should be available; but there may be cases where caller cannot provide it and
null is passed instead (in which case impls usually pass 'this' serializer as is) property)Implements com. Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property. |
| protected Object | findProxied(HibernateProxy proxy)
Helper method for finding value being proxied, if it is available or if it is to be forced to be loaded. |
| protected JsonSerializer | |
| private String | Returns: Name of the identity property of the specified lazy initializer.Lazy initializer to obtain identifier property name from. init)Helper method to retrieve the name of the identifier property of the specified lazy initializer. |
| public boolean | isEmpty(SerializerProvider provider, HibernateProxy value)
Overrides com. Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values). |
| public boolean | isUnwrappingSerializer()
Overrides com. Accessor for checking whether this serializer is an "unwrapping" serializer; this is necessary to know since it may also require caller to suppress writing of the leading property name. |
| public void | serialize(HibernateProxy
Value to serialize; can not be null. value, JsonGenerator Generator used to output resulting Json content g, SerializerProvider Provider that can be used to get serializers for
serializing Objects value contains, if any. provider)Implements abstract com. Method that can be called to ask implementation to serialize values of type this serializer handles. |
| public void | serializeWithType(HibernateProxy
Value to serialize; can not be null. value, JsonGenerator Generator used to output resulting Json content g, SerializerProvider Provider that can be used to get serializers for
serializing Objects value contains, if any. provider, TypeSerializer Type serializer to use for including type information typeSer)Overrides com. Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information. |
| public JsonSerializer | unwrappingSerializer(final NameTransformer
Name transformation to use to convert between names
of unwrapper properties unwrapper)Overrides com. Method that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output). |
| _dynamicSerializers | back to summary |
|---|---|
| protected PropertySerializerMap _dynamicSerializers For efficient serializer lookup, let's use this; most of the time, there's just one type and one serializer. | |
| _forceLazyLoading | back to summary |
|---|---|
| protected final boolean _forceLazyLoading | |
| _mapping | back to summary |
|---|---|
| protected final Mapping _mapping | |
| _nullMissingEntities | back to summary |
|---|---|
| protected final boolean _nullMissingEntities | |
| _property | back to summary |
|---|---|
| protected final BeanProperty _property Property that has proxy value to handle | |
| _serializeIdentifier | back to summary |
|---|---|
| protected final boolean _serializeIdentifier | |
| _unwrapper | back to summary |
|---|---|
| protected final NameTransformer _unwrapper | |
| _wrappedIdentifier | back to summary |
|---|---|
| protected final boolean _wrappedIdentifier | |
| Hibernate5JProxySerializer | back to summary |
|---|---|
| public Hibernate5JProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, Mapping mapping) | |
| Hibernate5JProxySerializer | back to summary |
|---|---|
| public Hibernate5JProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, boolean nullMissingEntities, boolean wrappedIdentifier, Mapping mapping, BeanProperty property, NameTransformer unwrapper) | |
| Hibernate5JProxySerializer | back to summary |
|---|---|
| protected Hibernate5JProxySerializer(Hibernate5JProxySerializer base, BeanProperty property, NameTransformer unwrapper) | |
| acceptJsonFormatVisitor | back to summary |
|---|---|
| public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException Overrides com. Implements com. Doc from com. Default implementation simply calls
| |
| createContextual | back to summary |
|---|---|
| public JsonSerializer Implements com. Doc from com. Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property. Note that instance that this method is called on is typically shared one and as a result method should NOT modify this instance but rather construct and return a new instance. This instance should only be returned as-is, in case it is already suitable for use.
| |
| findProxied | back to summary |
|---|---|
| protected Object findProxied(HibernateProxy proxy) Helper method for finding value being proxied, if it is available or if it is to be forced to be loaded. | |
| findSerializer | back to summary |
|---|---|
| protected JsonSerializer | |
| getIdentifierPropertyName | back to summary |
|---|---|
| private String getIdentifierPropertyName(final LazyInitializer init) Helper method to retrieve the name of the identifier property of the specified lazy initializer.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty(SerializerProvider provider, HibernateProxy value) Overrides com. Doc from com. Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values). Default implementation will consider only null values to be empty. Note replaces
| |
| isUnwrappingSerializer | back to summary |
|---|---|
| public boolean isUnwrappingSerializer() Overrides com. Doc from com. Accessor for checking whether this serializer is an "unwrapping" serializer; this is necessary to know since it may also require caller to suppress writing of the leading property name.
| |
| serialize | back to summary |
|---|---|
| public void serialize(HibernateProxy value, JsonGenerator g, SerializerProvider provider) throws IOException Implements abstract com. Doc from com. Method that can be called to ask implementation to serialize values of type this serializer handles.
| |
| serializeWithType | back to summary |
|---|---|
| public void serializeWithType(HibernateProxy value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException Overrides com. Doc from com. Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.
Default implementation will throw For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like: // note: method to call depends on whether this type is serialized as JSON scalar, object or Array! typeSer.writeTypePrefixForScalar(value, gen); serialize(value, gen, provider); typeSer.writeTypeSuffixForScalar(value, gen);and implementations for type serialized as JSON Arrays or Objects would differ slightly, as START-ARRAY/END-ARRAY and
START-OBJECT/END-OBJECT pairs
need to be properly handled with respect to serializing of contents.
| |
| unwrappingSerializer | back to summary |
|---|---|
| public JsonSerializer Overrides com. Doc from com. Method that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output). If no unwrapped serializer can be constructed, will simply return serializer as-is. Default implementation just returns serializer as-is, indicating that no unwrapped variant exists
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final Field |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static String | Returns: the name of the identifier property, or null if the name could not be determined
|
| getIdentifierMethodField | back to summary |
|---|---|
| private static final Field getIdentifierMethodField | |
| ProxyReader | back to summary |
|---|---|
| protected ProxyReader() | |
| getIdentifierPropertyName | back to summary |
|---|---|
pack-priv static String getIdentifierPropertyName(LazyInitializer init)
| |
| Modifier and Type | Field and Description |
|---|---|
| protected static final Method | lazyInitializerGetSessionMethod
The getSession method must be executed using reflection for compatibility purpose. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static String |
| lazyInitializerGetSessionMethod | back to summary |
|---|---|
| protected static final Method lazyInitializerGetSessionMethod The getSession method must be executed using reflection for compatibility purpose. For efficiency keep the method cached. | |
| ProxySessionReader | back to summary |
|---|---|
| protected ProxySessionReader() | |
| getIdentifierPropertyName | back to summary |
|---|---|
| pack-priv static String getIdentifierPropertyName(LazyInitializer init) | |