当前位置: 首页>>代码示例>>Java>>正文


Java Hibernate4Module类代码示例

本文整理汇总了Java中com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module的典型用法代码示例。如果您正苦于以下问题:Java Hibernate4Module类的具体用法?Java Hibernate4Module怎么用?Java Hibernate4Module使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Hibernate4Module类属于com.fasterxml.jackson.datatype.hibernate4包,在下文中一共展示了Hibernate4Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jacksonMessageConverter

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
private MappingJackson2HttpMessageConverter jacksonMessageConverter() {
    MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Hibernate4Module().enable(Hibernate4Module.Feature.USE_TRANSIENT_ANNOTATION));
    messageConverter.setObjectMapper(mapper);
    return messageConverter;
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:8,代码来源:CloudUnitApplicationContext.java

示例2: jacksonMessageConverter

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
private MappingJackson2HttpMessageConverter jacksonMessageConverter() {
	MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
	ObjectMapper mapper = new ObjectMapper();
	Hibernate4Module hibernate4Module = new Hibernate4Module();
	hibernate4Module.configure(Feature.FORCE_LAZY_LOADING, true);
	hibernate4Module.configure(Feature.USE_TRANSIENT_ANNOTATION, false);
	mapper.registerModule(hibernate4Module);
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
	mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
	messageConverter.setObjectMapper(mapper);
	return messageConverter;
}
 
开发者ID:JordanEC,项目名称:SpringBootRestAPIStormpath,代码行数:14,代码来源:WebConfiguration.java

示例3: jacksonObjectMapper

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
@Bean
public ObjectMapper jacksonObjectMapper() {
  ObjectMapper mapper = new ObjectMapper();

  mapper.setVisibility(
      mapper.getSerializationConfig().getDefaultVisibilityChecker()
          .withFieldVisibility(Visibility.ANY)
          .withGetterVisibility(Visibility.NONE)
          .withSetterVisibility(Visibility.NONE)
          .withCreatorVisibility(Visibility.NONE)
          .withIsGetterVisibility(Visibility.NONE));
  SimpleModule module = new SimpleModule("bandwidth-on-demand", Version.unknownVersion());
  module.addSerializer(new VlanJsonSerializer());
  module.addDeserializer(Vlan.class, new VlanJsonDeserializer());
  module.addSerializer(new ScheduleTypeJsonSerializer());
  module.addDeserializer(ScheduleType.class, new ScheduleTypeJsonDeserializer());
  mapper.registerModule(module);
  mapper.registerModule(new Hibernate4Module());
  mapper.registerModule(new JodaModule());
  mapper.registerModule(new Jdk8Module());
  mapper.registerModule(new JavaTimeModule());
  mapper.registerSubtypes(new NamedType(LocalVirtualPort.class, "LOCAL"));
  mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

  return mapper;
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:27,代码来源:AppComponents.java

示例4: addsHibernateSupportToJackson

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的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(Hibernate4Module.class);
}
 
开发者ID:mtakaki,项目名称:CredentialStorageService-dw-hibernate,代码行数:15,代码来源:HibernateBundleTest.java

示例5: jacksonMessageConverter

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
private MappingJackson2HttpMessageConverter jacksonMessageConverter() {
	MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
	ObjectMapper mapper = new ObjectMapper();
	Hibernate4Module hibernate4Module = new Hibernate4Module();
	hibernate4Module.configure(Feature.FORCE_LAZY_LOADING, true);
	mapper.registerModule(hibernate4Module);
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);
	mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
	mapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false);
	mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
	messageConverter.setObjectMapper(mapper);
	return messageConverter;
}
 
开发者ID:JordanEC,项目名称:RestApiSpringBootExample,代码行数:15,代码来源:WebConfiguration.java

示例6: JacksonProvider

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
public JacksonProvider() {
	AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
	// if using BOTH JAXB annotations AND Jackson annotations:
	AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();

	ObjectMapper mapper = new ObjectMapper().registerModule(new Hibernate4Module())
			.setSerializationInclusion(Include.NON_NULL)
			.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false).enable(SerializationFeature.INDENT_OUTPUT)
			.setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary));
	// mapper = mapper.setSerializationInclusion(Include)
	setMapper(mapper);
}
 
开发者ID:infinitiessoft,项目名称:keystone4j,代码行数:13,代码来源:JacksonProvider.java

示例7: ObjectMapperResolver

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
public ObjectMapperResolver() {
	objectMapper = new ObjectMapper();
	AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
	AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
	objectMapper = objectMapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary));
	objectMapper = objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
	objectMapper.registerModule(new Hibernate4Module());
}
 
开发者ID:infinitiessoft,项目名称:keystone4j,代码行数:9,代码来源:ObjectMapperResolver.java

示例8: jacksonMessageConverter

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
/**
	 * Jackson message converter.
	 *
	 * @return the mapping jackson2 http message converter
	 */
	public MappingJackson2HttpMessageConverter jacksonMessageConverter() {
		MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();

		ObjectMapper mapper = new ObjectMapper();
		
		Hibernate4Module hibernate4Module = new Hibernate4Module();
        hibernate4Module.disable(Hibernate4Module.Feature.USE_TRANSIENT_ANNOTATION);
        
        mapper.registerModule(hibernate4Module);
//      mapper.registerModule(new Hibernate3Module());
//		mapper.registerModule(new Jdk7Module());
//		mapper.registerModule(new Jdk8Module());
//		mapper.registerModule(new JSR310Module());
		
//		SimpleModule  module = new SimpleModule();
//		module.addDeserializer(ServHotel.class, new JSOGRefDeserializer());
//		module.addDeserializer(SObject.class, new JSOGRefDeserializer());
//		module.addDeserializer(SView.class, new JSOGRefDeserializer());
//		mapper.registerModule(module);
		
        mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
        mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
        mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
        mapper.setSerializationInclusion(Include.NON_NULL);
        DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
        dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Dhaka"));
        mapper.setDateFormat(dateFormat);
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
		
		if (debug) {
			messageConverter.setPrettyPrint(true);
		}

		messageConverter.setObjectMapper(mapper);
		return messageConverter;
	}
 
开发者ID:gleb619,项目名称:hotel_shop,代码行数:43,代码来源:WebMvcConfigurerAdapterConfig.java

示例9: objectMapper

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
@Provides
@Singleton
ObjectMapper objectMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    // Hibernate 4 Module handles lazy loading and other Hibernate stuffz
    mapper.writerWithDefaultPrettyPrinter();
    mapper.registerModule(new Hibernate4Module());
    return mapper;
}
 
开发者ID:TechnoJays,项目名称:First-Dash-Service,代码行数:10,代码来源:JSONInjection.java

示例10: configure

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
public static ObjectMapper configure(ObjectMapper objectMapper) {
    // need to prevent hibernate lazy initialization errors during serialization
    objectMapper.registerModule(new Hibernate4Module());

    // Allow serialization of "empty" POJOs (no properties to serialize)
    // (without this setting, an exception is thrown in those cases)
    objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);

    // Write java.util.Date, Calendar as number (timestamp)
    objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    objectMapper.disable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS);

    // Prevent exception when encountering unknown property
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

    // Coerce JSON empty String ("") to null
    objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);

    // Coerce unknown enum to null
    objectMapper.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL);

    objectMapper.enable(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN);
    objectMapper.setNodeFactory(JsonNodeFactory.withExactBigDecimals(true));
    objectMapper.registerModule(BIG_DECIMAL_MODULE);

    // Force escaping of non-ASCII characters
    objectMapper.configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, true);

    return objectMapper;
}
 
开发者ID:wmluke,项目名称:pipes,代码行数:31,代码来源:JacksonJsonConfig.java

示例11: jacksonMessageConverter

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
@Bean
public MappingJackson2HttpMessageConverter jacksonMessageConverter() {
    MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
    ObjectMapper mapper = new ObjectMapper();
    //Registering Hibernate4Module to support lazy objects
    mapper.registerModule(new Hibernate4Module());
    messageConverter.setObjectMapper(mapper);
    return messageConverter;
}
 
开发者ID:aemreunal,项目名称:iBeaconServer,代码行数:10,代码来源:MVCConfig.java

示例12: HibernateLazyLoadModule

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
/**
 * Default constructor.
 */
public HibernateLazyLoadModule() {
    super();

    this.disable(Hibernate4Module.Feature.FORCE_LAZY_LOADING);
    this.enable(Hibernate4Module.Feature.SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS);
}
 
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:10,代码来源:Helper.java

示例13: init

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
@Override
public void init() {
	super.init();
	Hibernate4Module module = new Hibernate4Module();
	module.configure(Feature.FORCE_LAZY_LOADING, true);
	getObjectMapper().registerModule(module);
}
 
开发者ID:minnal,项目名称:minnal,代码行数:8,代码来源:PetclinicApplication.java

示例14: jsonMapper

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
/**
 * Configure a Jackson {@link ObjectMapper}
 * with the {@link Hibernate4Module} so 
 * that JPA objects are correctly 
 * serialized (e.g. lazy associations 
 * aren't automatically serialized)
 * @return configured {@link ObjectMapper}
 */
@Bean(name="jsonMapper")
public ObjectMapper jsonMapper() {
	ObjectMapper mapper = new ObjectMapper();
	Hibernate4Module hm = new Hibernate4Module();
	hm.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, false);
	mapper.registerModule(hm);
	mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
	mapper.setSerializationInclusion(Include.NON_NULL); // This doesn't work with Hibernate4Module :-(
	return mapper;
}
 
开发者ID:patrickvankann,项目名称:bjug-querydsl,代码行数:19,代码来源:WebConfig.java

示例15: ObjectMapperProvider

import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; //导入依赖的package包/类
public ObjectMapperProvider() {
	//mapper.addMixInAnnotations(People.class, PeopleMixIn.class);
	//mapper.getSerializationConfig().setSerializationView(Views.LimitedView.class);
       //mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
       mapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
       //mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
       mapper.registerModule(new Hibernate4Module());


}
 
开发者ID:smysnk,项目名称:dockyard-controller,代码行数:11,代码来源:ObjectMapperProvider.java


注:本文中的com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。