當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。