Skip to content

Commit

Permalink
Fix for #1858
Browse files Browse the repository at this point in the history
  • Loading branch information
pvncoder authored and beikov committed Jan 25, 2024
1 parent 191e130 commit e324501
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ public class BlazePersistenceWebConfiguration implements WebMvcConfigurer {
protected final ObjectMapper objectMapper;
private final EntityViewManager entityViewManager;

public BlazePersistenceWebConfiguration(
EntityViewManager entityViewManager,
@Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService,
@Autowired(required = false) ObjectMapper objectMapper
) {
public BlazePersistenceWebConfiguration(EntityViewManager entityViewManager,
@Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService,
@Autowired(required = false) ObjectMapper objectMapper) {
this.entityViewManager = entityViewManager;
this.conversionService = conversionService;
this.objectMapper = objectMapper == null ? new ObjectMapper() : objectMapper.copy();
Expand Down Expand Up @@ -87,7 +85,7 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentRes
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
// Add it to the beginning, so it has precedence over the builtin
converters.add(0, new EntityViewAwareMappingJackson2HttpMessageConverter(entityViewManager, blazeWebmvcIdAttributeAccessor()));
converters.add(0, new EntityViewAwareMappingJackson2HttpMessageConverter(entityViewManager, blazeWebmvcIdAttributeAccessor(), objectMapper()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.blazebit.persistence.integration.jackson.EntityViewIdValueAccessor;
import com.blazebit.persistence.view.EntityViewManager;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageNotReadableException;
Expand All @@ -38,8 +39,9 @@ public class EntityViewAwareMappingJackson2HttpMessageConverter extends MappingJ

private final EntityViewAwareObjectMapper entityViewAwareObjectMapper;

public EntityViewAwareMappingJackson2HttpMessageConverter(final EntityViewManager entityViewManager, EntityViewIdValueAccessor entityViewIdValueAccessor) {
this.entityViewAwareObjectMapper = new EntityViewAwareObjectMapper(entityViewManager, getObjectMapper(), entityViewIdValueAccessor);
public EntityViewAwareMappingJackson2HttpMessageConverter(final EntityViewManager entityViewManager, EntityViewIdValueAccessor entityViewIdValueAccessor, ObjectMapper objectMapper) {
super(objectMapper);
this.entityViewAwareObjectMapper = new EntityViewAwareObjectMapper(entityViewManager, objectMapper, entityViewIdValueAccessor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@
*/
@Configuration
public class BlazePersistenceWebConfiguration extends WebMvcConfigurerAdapter {

protected final ObjectFactory<ConversionService> conversionService;
protected final ObjectMapper objectMapper;
private final EntityViewManager entityViewManager;

public BlazePersistenceWebConfiguration(
EntityViewManager entityViewManager,
@Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService,
@Autowired(required = false) ObjectMapper objectMapper
) {
public BlazePersistenceWebConfiguration(EntityViewManager entityViewManager,
@Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService,
@Autowired(required = false) ObjectMapper objectMapper) {
this.entityViewManager = entityViewManager;
this.conversionService = conversionService;
this.objectMapper = objectMapper == null ? new ObjectMapper() : objectMapper.copy();
Expand Down Expand Up @@ -87,7 +86,7 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentRes
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
// Add it to the beginning so it has precedence over the builtin
converters.add(0, new EntityViewAwareMappingJackson2HttpMessageConverter(entityViewManager, blazeWebmvcIdAttributeAccessor()));
converters.add(0, new EntityViewAwareMappingJackson2HttpMessageConverter(entityViewManager, blazeWebmvcIdAttributeAccessor(), objectMapper()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.blazebit.persistence.integration.jackson.EntityViewIdValueAccessor;
import com.blazebit.persistence.view.EntityViewManager;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageNotReadableException;
Expand All @@ -37,8 +38,9 @@ public class EntityViewAwareMappingJackson2HttpMessageConverter extends MappingJ

private final EntityViewAwareObjectMapper entityViewAwareObjectMapper;

public EntityViewAwareMappingJackson2HttpMessageConverter(final EntityViewManager entityViewManager, EntityViewIdValueAccessor entityViewIdValueAccessor) {
this.entityViewAwareObjectMapper = new EntityViewAwareObjectMapper(entityViewManager, getObjectMapper(), entityViewIdValueAccessor);
public EntityViewAwareMappingJackson2HttpMessageConverter(final EntityViewManager entityViewManager, EntityViewIdValueAccessor entityViewIdValueAccessor, ObjectMapper objectMapper) {
super(objectMapper);
this.entityViewAwareObjectMapper = new EntityViewAwareObjectMapper(entityViewManager, objectMapper, entityViewIdValueAccessor);
}

@Override
Expand Down

0 comments on commit e324501

Please sign in to comment.