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


Java ValidationMode类代码示例

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


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

示例1: entityManagerFactoryBean

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
	Map<String, Object> properties = new Hashtable<>();
	properties.put("javax.persistence.schema-generation.database.action", "none");
	properties.put("hibernate.connection.characterEncoding", "utf8");
	properties.put("hibernate.connection.useUnicode", "true");
	properties.put("hibernate.connection.charSet", "utf8");
	properties.put("hibernate.search.default.directory_provider", "filesystem");
	properties.put("hibernate.search.default.indexBase", context.getInitParameter("indexDir"));

	HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
	adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(adapter);
	factory.setDataSource(this.bookManagerDataSource());
	factory.setPackagesToScan("net.viperfish.bookManager");
	factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
	factory.setValidationMode(ValidationMode.NONE);
	factory.setJpaPropertyMap(properties);
	return factory;
}
 
开发者ID:shilongdai,项目名称:bookManager,代码行数:23,代码来源:RootApplicationContextConfig.java

示例2: entityManagerFactory

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Bean
@DependsOn(value = {"simpleApplicationContextHolder"})
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    factoryBean.setValidationMode(ValidationMode.CALLBACK);
    factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
    factoryBean.setPackagesToScan("com.devicehive.model");

    final Properties props = new Properties();
    props.putAll(this.properties.getHibernateProperties(this.dataSource));
    if (useNativeClient) {
        props.put("hibernate.cache.hazelcast.native_client_group", groupName);
        props.put("hibernate.cache.hazelcast.native_client_password", groupPassword);
        if (!CollectionUtils.isEmpty(clusterMembers)) {
            props.put("hibernate.cache.hazelcast.native_client_address", clusterMembers.get(0));
        }
    }

    factoryBean.setJpaProperties(props);
    return factoryBean;
}
 
开发者ID:devicehive,项目名称:devicehive-java-server,代码行数:24,代码来源:RdbmsPersistenceConfig.java

示例3: endElement

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Override
public void endElement(String uri, String localName, String name) throws SAXException {
    String s = builder.toString().trim();
    // This step is VERY important, otherwise we pollute subsequent
    // elements
    builder = new StringBuilder();

    if ("".equals(s))
        return;

    PersistenceUnit pu = persistenceUnits.peek();

    if ("provider".equals(elementName))
        pu.setProviderClassName(s);
    else if ("jta-data-source".equals(elementName))
        pu.setJtaDataSourceName(s);
    else if ("non-jta-data-source".equals(elementName))
        pu.setNonJtaDataSourceName(s);
    else if ("class".equals(elementName))
        pu.addClassName(s);
    else if("mapping-file".equals(elementName))
    	pu.addMappingFile(s);
    else if ("exclude-unlisted-classes".equals(elementName))
        pu.setExcludeUnlisted(Boolean.parseBoolean(s));
    else if ("shared-cache-mode".equals(elementName))
        pu.setSharedCacheMode(SharedCacheMode.valueOf(s));
    else if ("validation-mode".equals(elementName))
        pu.setValidationMode(ValidationMode.valueOf(s));
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:30,代码来源:JPAHandler.java

示例4: entityManagerFactoryBean

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    Map<String, Object> properties = new HashMap<>();
    // properties.put("javax.persistence.schema-generation.database.action", "none"); // 没有update选项,只有:none、create、drop-and-create、drop,不满足开发需求
    // properties.put("hibernate.hbm2ddl.auto", "update"); // 使用adapter.setGenerateDdl(true),避免拼写错误;
    properties.put("hibernate.ejb.use_class_enhancer", "true");
    properties.put("hibernate.search.default.directory_provider", "filesystem");
    properties.put("hibernate.search.lucene_version", "5.3.1"); // 避免控制台警告,默认使用LUCENE_CURRENT
    properties.put("hibernate.search.default.indexBase", "../amanda/searchIndexes");

    // properties.put("hibernate.show_sql", "true");
    // properties.put("hibernate.format_sql", "true");
    properties.put("hibernate.use_sql_comments", "true");
    properties.put("hibernate.physical_naming_strategy", "com.timeyang.amanda.core.jpa.naming.PhysicalNamingStrategyImpl");

    LocalContainerEntityManagerFactoryBean factory =
            new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(this.dataSource);
    factory.setJpaVendorAdapter(jpaVendorAdapter());
    factory.setPackagesToScan(AmandaApplication.class.getPackage().getName());
    factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    factory.setValidationMode(ValidationMode.NONE);
    factory.setLoadTimeWeaver(this.loadTimeWeaver()); // TODO: remove when SPR-10856 fixed
    factory.setJpaPropertyMap(properties);
    return factory;
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:27,代码来源:RootContextConfiguration.java

示例5: createPersistenceUnitInfo

import javax.persistence.ValidationMode; //导入依赖的package包/类
private PersistenceUnitInfo createPersistenceUnitInfo() {
    PersistenceUnitInfo persistenceUnitInfo = mock(PersistenceUnitInfo.class);
    when(persistenceUnitInfo.getPersistenceUnitRootUrl()).thenReturn(createPersistenceUnitRootUrl());
    when(persistenceUnitInfo.getPersistenceUnitName()).thenReturn("annotation-based-field-access");
    when(persistenceUnitInfo.getTransactionType())
        .thenReturn(PersistenceUnitTransactionType.RESOURCE_LOCAL);
    when(persistenceUnitInfo.getValidationMode()).thenReturn(ValidationMode.AUTO);
    when(persistenceUnitInfo.getSharedCacheMode()).thenReturn(SharedCacheMode.UNSPECIFIED);
    when(persistenceUnitInfo.getJtaDataSource()).thenReturn(null);
    when(persistenceUnitInfo.getNonJtaDataSource()).thenReturn(null);
    when(persistenceUnitInfo.getNewTempClassLoader()).thenReturn(null);
    when(persistenceUnitInfo.getMappingFileNames()).thenReturn(Collections.<String>emptyList());
    when(persistenceUnitInfo.getJarFileUrls()).thenReturn(Collections.<URL>emptyList());
    when(persistenceUnitInfo.getPersistenceProviderClassName())
        .thenReturn(SecurePersistenceProvider.class.getName());
    when(persistenceUnitInfo.getClassLoader())
        .thenReturn(Thread.currentThread().getContextClassLoader());
    when(persistenceUnitInfo.getManagedClassNames()).thenReturn(Arrays.asList(
        FieldAccessAnnotationTestBean.class.getName(),
        FieldAccessMapKey.class.getName(),
        FieldAccessMapValue.class.getName()
    ));
    when(persistenceUnitInfo.excludeUnlistedClasses()).thenReturn(true);
    Properties properties = new Properties();
    properties.put("org.jpasecurity.persistence.provider", "org.hibernate.ejb.HibernatePersistence");
    properties.put("org.jpasecurity.security.context",
                   "org.jpasecurity.security.authentication.TestSecurityContext");
    properties.put("org.jpasecurity.security.rules.provider",
                   "org.jpasecurity.security.rules.XmlAccessRulesProvider");
    properties.put("hibernate.hbm2ddl.auto", "create-drop");
    properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
    properties.put("hibernate.connection.url", "jdbc:hsqldb:mem:test");
    properties.put("hibernate.connection.username", "sa");
    properties.put("hibernate.connection.password", "");
    when(persistenceUnitInfo.getProperties()).thenReturn(properties);
    return persistenceUnitInfo;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:39,代码来源:SecurePersistenceProviderTest.java

示例6: entityManagerFactoryBean

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean()
		throws ConfigurationException, IOException {
	Map<String, Object> properties = new Hashtable<>();
	String indexPath = this.configuration().getString(GlobalConfig.INDEX_PATH);
	if (indexPath == null) {
		indexPath = GlobalConfig.INDEX_PATH_DEFAULT;
	}
	properties.put("javax.persistence.schema-generation.database.action", "none");
	properties.put("hibernate.connection.characterEncoding", "utf8");
	properties.put("hibernate.connection.useUnicode", "true");
	properties.put("hibernate.connection.charSet", "utf8");
	properties.put("hibernate.search.default.directory_provider", "filesystem");
	properties.put("hibernate.search.default.indexBase", indexPath);

	HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
	adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(adapter);
	factory.setDataSource(this.chatDataSource());
	factory.setPackagesToScan("net.viperfish.chatapplication");
	factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
	factory.setValidationMode(ValidationMode.NONE);
	factory.setJpaPropertyMap(properties);
	return factory;
}
 
开发者ID:shilongdai,项目名称:LSChatServer,代码行数:28,代码来源:ApplicationRootContext.java

示例7: getVendorProperties

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Override
protected Map<String, Object> getVendorProperties() {
    LOGGER.info("PersistenceConfiguration.getVendorProperties()");
    HashMap<String, Object> vendorProperties = new HashMap<>();
    vendorProperties.put(PersistenceUnitProperties.WEAVING, detectWeavingMode());
    vendorProperties.put(PersistenceUnitProperties.VALIDATION_MODE, ValidationMode.NONE.toString());
    return vendorProperties;
}
 
开发者ID:fdlessard,项目名称:SpringBootMagicEightBallProject,代码行数:9,代码来源:PersistenceConfiguration.java

示例8: getValidationMode

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Override
public ValidationMode getValidationMode() {
    if (definition.validationMode.isEmpty()) {
        return ValidationMode.AUTO;
    }
    return ValidationMode.valueOf(definition.validationMode);
}
 
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:8,代码来源:PersistenceUnitInfoImpl.java

示例9: getValidationMode

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Override
public ValidationMode getValidationMode() {
    PersistenceUnitValidationModeType validationMode = persistenceUnitXml.getValidationMode();
    if (validationMode == null) {
        return null;
    }

    return ValidationMode.valueOf(validationMode.name());
}
 
开发者ID:wisdom-framework,项目名称:wisdom-jdbc,代码行数:10,代码来源:PersistenceUnitComponent.java

示例10: getValidationMode

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Override
public ValidationMode getValidationMode() {
	PersistenceUnitValidationModeType validationMode = persistenceUnitXml.getValidationMode();
	if (validationMode == null)
		return null;

	return ValidationMode.valueOf(validationMode.name());
}
 
开发者ID:osgi,项目名称:bundles,代码行数:9,代码来源:PersistenceUnitInfoImpl.java

示例11: createFactory

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Before
public void createFactory() throws MalformedURLException {
    GetterPersistenceUnitInfo info = new GetterPersistenceUnitInfo();
    info.setClassLoader(Thread.currentThread().getContextClassLoader());
    //we explicitly list them to avoid scanning
    info.setExcludeUnlistedClasses(true);
    info.setJtaDataSource(new NoopDatasource());
    List<String> classNames = new ArrayList<String>();
    for (Class<?> clazz : getEntities()) {
        classNames.add(clazz.getName());
    }
    info.setManagedClassNames(classNames);
    info.setNonJtaDataSource(null);
    info.setPersistenceProviderClassName(HibernateOgmPersistence.class.getName());
    info.setPersistenceUnitName("default");
    final URL persistenceUnitRootUrl = new File("").toURL();
    info.setPersistenceUnitRootUrl(persistenceUnitRootUrl);
    info.setPersistenceXMLSchemaVersion("2.0");
    info.setProperties(new Properties());
    info.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    info.setTransactionType(PersistenceUnitTransactionType.JTA);
    info.setValidationMode(ValidationMode.AUTO);
    info.getProperties().setProperty(Environment.JTA_PLATFORM,
                                     JBossStandAloneJtaPlatform.class.getName()
    );

    // MassIndexerFactoryIntegrator is defined at 4.3.0
    // info.getProperties().setProperty(MassIndexerFactoryIntegrator.MASS_INDEXER_FACTORY_CLASSNAME, OgmMassIndexerFactory.class.getName());
    for (Map.Entry<String, String> entry : TestHelper.getEnvironmentProperties().entrySet()) {
        info.getProperties().setProperty(entry.getKey(), entry.getValue());
    }
    refineInfo(info);

    factory = new HibernateOgmPersistence().createContainerEntityManagerFactory(info, Collections.EMPTY_MAP);
    transactionManager = extractJBossTransactionManager(factory);
}
 
开发者ID:debop,项目名称:debop4j,代码行数:37,代码来源:JpaTestBase.java

示例12: getValidationMode

import javax.persistence.ValidationMode; //导入依赖的package包/类
public ValidationMode getValidationMode() {
    if (validationMode == null) {
        final String propConfig = getProperty("javax.persistence.validation.mode");
        if (propConfig != null) {
            try {
                validationMode = ValidationMode.valueOf(propConfig.toUpperCase());
            } catch (final IllegalArgumentException iae) { // can happen since some provider allow more than the enum
                // no-op
            }
        }
    }
    return (validationMode == null) ? ValidationMode.AUTO : validationMode;
}
 
开发者ID:apache,项目名称:tomee,代码行数:14,代码来源:PersistenceUnit.java

示例13: setValidationMode

import javax.persistence.ValidationMode; //导入依赖的package包/类
public synchronized void setValidationMode(final ValidationMode mode) {
    final PersistenceUnitInfoImpl info = entityManagerFactoryCallable.getUnitInfo();
    info.setValidationMode(mode);

    final Properties properties = entityManagerFactoryCallable.getUnitInfo().getProperties();
    if (properties.containsKey(JAVAX_PERSISTENCE_VALIDATION_MODE)) {
        properties.setProperty(JAVAX_PERSISTENCE_VALIDATION_MODE, mode.name());
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:10,代码来源:ReloadableEntityManagerFactory.java

示例14: possible

import javax.persistence.ValidationMode; //导入依赖的package包/类
@ManagedOperation
@Description("change the validation mode if possible (value is ok)")
public void setValidationMode(final String value) {
    try {
        final ValidationMode mode = ValidationMode.valueOf(value.trim().toUpperCase());
        reloadableEntityManagerFactory.setValidationMode(mode);
    } catch (final Exception iae) {
        LOGGER.warning("Can't set validation mode " + value, iae);
        reloadableEntityManagerFactory.setProperty(JAVAX_PERSISTENCE_VALIDATION_MODE, value);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:12,代码来源:ReloadableEntityManagerFactory.java

示例15: getValidationMode

import javax.persistence.ValidationMode; //导入依赖的package包/类
@Override
public ValidationMode getValidationMode() {
    String s = (String) parsedPersistenceUnit.getPersistenceXmlMetadata()
            .get(ParsedPersistenceUnit.VALIDATION_MODE);

    if (s == null) {
        return ValidationMode.AUTO;
    } else {
        return ValidationMode.valueOf(s);
    }
}
 
开发者ID:everit-org-archive,项目名称:osgi-jpa-container,代码行数:12,代码来源:PersistenceUnitInfoImpl.java


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