I have a java class as follows
@Data
@Document(collection="sample_collection")
public class sampleClass {
private Instant createTime;
private Object payLoad;
// some more fields
}
The payload object can be null or object of different classes, and can contain a field of type byteBuffer.
Now, while trying to save this to Mongo as a document, I get no issues, but which retrieving the document, I get the instantiationException( whenever the payload object is populated and has the byteBuffer field )
Below are the exception details:
org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate java.nio.HeapByteBuffer using constructor NO_CONSTRUCTOR with arguments
at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance
at org.springframework.data.convert.ClassGeneratingEntityInstantiator.createInstance
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read
I'm unable to find a way to define a constructor for the HeapByteBuffer field. Any leads would be appreciated.