Posts

Showing posts with the label serialization

How to serialize a json containing LAZY associations

How to serialize a json containing LAZY associations I am having an Person entity which has @ManyToOne association with Contact entity with fetch type LAZY. I am using spring-boot to expose REST API. One of my POST call contains nested JSON to save the parent entity Person along with association Contact Person @ManyToOne Contact Person Contact Since Contact fetch type is LAZY, I am encountering into following exception Contact ERROR 17415 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and ...

Ember change normalizeResponse based on queried model

Ember change normalizeResponse based on queried model I'm using a second datastore with my Ember app, so I can communicate with a separate external API. I have no control over this API. With a DS.JSONSerializer I can add some missing properties like id : DS.JSONSerializer id normalizeResponse(store, primaryModelClass, payload, id, requestType) { if (requestType == 'query') { payload.forEach(function(el, index) { payload[index].id = index }) } Now I can do some different tricks for each different requestType . But every response is parsed. Now sometimes a response from one request needs to be parsed differently. requestType So what I am trying to do is change the normalizeResponse functionality for each different request path (mapped to a fake model using pathForType in an adapter for this store). But the argument store is always the same (obviously) and the argument promaryModelClass is always "unknown mixin" - not sure ...