Skip to content

Commit

Permalink
correction suggestion to issue FasterXML#70
Browse files Browse the repository at this point in the history
  • Loading branch information
peruzzo committed Dec 29, 2015
1 parent 26ec7ea commit afe51ab
Showing 1 changed file with 19 additions and 0 deletions.
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);
}
}

0 comments on commit afe51ab

Please sign in to comment.