The easiest way to achieve this goal is to set the configuration property in the hibernate.properties file
hibernate.types.jackson.object.mapper=com.vladmihalcea.hibernate.type.json.loader.CustomObjectMapperSupplier
The CustomObjectMapperSupplier can look as follows:
public class CustomObjectMapperSupplier
implements ObjectMapperSupplier {
@Override
public ObjectMapper get() {
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
objectMapper.setTimeZone(
TimeZone.getTimeZone("GMT")
);
SimpleModule simpleModule = new SimpleModule(
"SimpleModule",
new Version(1, 0, 0, null, null, null)
);
simpleModule.addSerializer(new MoneySerializer());
objectMapper.registerModule(simpleModule);
return objectMapper;
}
}
Original link: How to customize the Jackson ObjectMapper used by Hibernate-Types