Skip to content

correction suggestion to issue #70 #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.fasterxml.jackson.core.*;

import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap;

import org.hibernate.engine.spi.Mapping;
Expand All @@ -27,6 +29,7 @@
*/
public class HibernateProxySerializer
extends JsonSerializer<HibernateProxy>
implements ContextualSerializer
{
/**
* Property that has proxy value to handle
Expand Down Expand Up @@ -66,6 +69,16 @@ public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdent
_property = null;
}

public HibernateProxySerializer(boolean forceLazyLoading, boolean serializeIdentifier, Mapping mapping, BeanProperty property) {
_forceLazyLoading = forceLazyLoading;
_serializeIdentifier = serializeIdentifier;
_mapping = mapping;
_dynamicSerializers = PropertySerializerMap.emptyForProperties();
_property = property;
}



/*
/**********************************************************************
/* JsonSerializer impl
Expand Down Expand Up @@ -165,4 +178,10 @@ protected Object findProxied(HibernateProxy proxy)
}
return init.getImplementation();
}

@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property)
throws JsonMappingException {
return new HibernateProxySerializer(this._forceLazyLoading, this._serializeIdentifier, this._mapping, property);
}
}