本文整理汇总了Java中com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module类的典型用法代码示例。如果您正苦于以下问题:Java Hibernate5Module类的具体用法?Java Hibernate5Module怎么用?Java Hibernate5Module使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Hibernate5Module类属于com.fasterxml.jackson.datatype.hibernate5包,在下文中一共展示了Hibernate5Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertParsedEventToOccurrence
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
private Occurrence convertParsedEventToOccurrence(final ScoredEntry<String> parsedEvent) {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new Hibernate5Module());
objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true);
try {
final ParsedEventData parsedEventData = objectMapper.readValue(parsedEvent.getValue(), ParsedEventData.class);
return occurrenceService.parseParsedEventData(parsedEventData);
} catch (IOException e) {
logger.info("[EventController] [convertEventCollectionToListOfOccurrences] Failure To Read JSON From Cache", e);
}
return null;
}
示例2: toJSON
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
/**
* Convert this object to json
*
* @return the json
*/
public String toJSON() {
String returnVar = "";
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new Hibernate5Module());
objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true);
try {
returnVar = objectMapper.writeValueAsString(this);
} catch (JsonProcessingException ex) {
logger.info("[DataObject] [toJson] Convert Object To JSON Failure", ex);
}
return returnVar;
}
示例3: configureObjectMapper
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
/**
* Utilisé pour pouvoir mapper correctement les objets Lazy loaded par hibernate
* @return
*/
@SuppressWarnings("unchecked")
@Bean
public Jackson2ObjectMapperBuilder configureObjectMapper() {
return new Jackson2ObjectMapperBuilder()
.modulesToInstall(Hibernate5Module.class);
}
示例4: main
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(SampleDataJpaApplication.class, args);
Iterable<ObjectMapper> objectMappers = context.getBeansOfType(ObjectMapper.class)
.values();
objectMappers.forEach(mapper -> mapper.registerModule(new Hibernate5Module()));
Squiggly.init(objectMappers, new RequestSquigglyContextProvider() {
@Override
public void serializeAsIncludedField(Object pojo, JsonGenerator jgen, SerializerProvider provider, PropertyWriter writer) throws Exception {
if (isFilteringEnabled()) {
Object value = writer.getMember().getValue(pojo);
if (value instanceof PersistentCollection) {
((PersistentCollection) value).forceInitialization();
}
}
super.serializeAsIncludedField(pojo, jgen, provider, writer);
}
});
ObjectMapper objectMapper = Iterables.getFirst(objectMappers, null);
// Enable Squiggly for Jackson message converter
if (objectMapper != null) {
for (MappingJackson2HttpMessageConverter converter : context.getBeansOfType(MappingJackson2HttpMessageConverter.class).values()) {
converter.setObjectMapper(objectMapper);
}
}
}
示例5: mappingJackson2HttpMessageConverter
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
@Bean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new Hibernate5Module());
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
jsonConverter.setObjectMapper(objectMapper);
return jsonConverter;
}
示例6: jacksonMessageConverter
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
private MappingJackson2HttpMessageConverter jacksonMessageConverter() {
final MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
final ObjectMapper mapper = new ObjectMapper();
//Registering Hibernate5Module to support lazy objects
mapper.registerModule(new Hibernate5Module());
messageConverter.setObjectMapper(mapper);
return messageConverter;
}
示例7: JacksonInitializer
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
public JacksonInitializer() {
mapper = new ObjectMapper()
.registerModule(new JSR310Module())
.registerModule(new Hibernate5Module())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
}
示例8: JacksonConfiguration
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
/**
* Default constructor, which creates the ObjectMapper and add the custom modules.
*/
public JacksonConfiguration() {
Hibernate5Module hibernate5Module = new Hibernate5Module();
hibernate5Module.configure(Hibernate5Module.Feature.USE_TRANSIENT_ANNOTATION, false);
mapper = new ObjectMapper();
mapper.registerModule(hibernate5Module);
}
示例9: initialize
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
@Override
public final void initialize(Bootstrap<?> bootstrap) {
Hibernate5Module module = createHibernate5Module();
configure(module);
bootstrap.getObjectMapper().registerModule(module);
initialized = true;
}
示例10: createHibernate5Module
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
private Hibernate5Module createHibernate5Module() {
Hibernate5Module module = new Hibernate5Module();
if (serializeLazyLoadedEntitiesEnabled) {
module.enable(Hibernate5Module.Feature.FORCE_LAZY_LOADING);
}
return module;
}
示例11: addsHibernateSupportToJackson
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
@Test
public void addsHibernateSupportToJackson() throws Exception {
final ObjectMapper objectMapperFactory = mock(ObjectMapper.class);
final Bootstrap<?> bootstrap = mock(Bootstrap.class);
when(bootstrap.getObjectMapper()).thenReturn(objectMapperFactory);
bundle.initialize(bootstrap);
final ArgumentCaptor<Module> captor = ArgumentCaptor.forClass(Module.class);
verify(objectMapperFactory).registerModule(captor.capture());
assertThat(captor.getValue()).isInstanceOf(Hibernate5Module.class);
}
示例12: createHibernate5Module
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
/**
* read more https://github.com/dropwizard/dropwizard/issues/932
*
* @return Hibernate4Module
*/
@Override
protected Hibernate5Module createHibernate5Module() {
Hibernate5Module module = new Hibernate5Module();
module.disable(Hibernate5Module.Feature.USE_TRANSIENT_ANNOTATION);
return module;
}
示例13: getHibernate5Module
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
@Test
@Order(order = 6)
public void getHibernate5Module() {
Hibernate5Module hibernate5Module = RobeHibernateBundle.getInstance().createHibernate5Module();
Assert.assertNotNull(hibernate5Module);
Assert.assertFalse(hibernate5Module.isEnabled(Hibernate5Module.Feature.USE_TRANSIENT_ANNOTATION));
}
示例14: createHibernate5Module
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
@Override
protected Hibernate5Module createHibernate5Module() {
Hibernate5Module module = super.createHibernate5Module();
// allow @Transient JPA annotation process by Jackson
module.disable(Hibernate5Module.Feature.FORCE_LAZY_LOADING);
module.disable(Hibernate5Module.Feature.USE_TRANSIENT_ANNOTATION);
return module;
}
示例15: initialize
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<PirateConfiguration> bootstrap) {
bootstrap.addBundle(hibernateBundle);
final XmlBundle xmlBundle = new XmlBundle();
xmlBundle.getXmlMapper()
.enable(INDENT_OUTPUT)
.setSerializationInclusion(NON_NULL)
.registerModule(new Hibernate5Module());
bootstrap.addBundle(xmlBundle);
}