I am having trouble configuring the default ObjectMapper in JHipster to allow JsonViews and also setting to false the FORCE_LAZY_LOADING
property of the Hibernate4Module
module.
I have tried three things without success:
1) Create a @Bean
using the @Primary
annotation to replace the default bean:
@Bean
@Primary
public ObjectMapper viewsObjectMapper(){
ObjectMapper mapper = new ObjectMapper();
Hibernate4Module hibernateModule = new Hibernate4Module();
hibernateModule.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, false); mapper.registerModule(hibernateModule);
mapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION);
return mapper;
}
2) I modified the @Bean
Hibernate4Module
in the DatabaseConfiguration
class as follows:
@Bean
public Hibernate4Module hibernate4Module() {
Hibernate4Module hibernateModule = new Hibernate4Module();
hibernateModule.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, true);
return hibernateModule;
}
3) And this solution.
Any help will be appreciated.