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


Java AvailableSettings类代码示例

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


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

示例1: setUp

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
/**
 */
@Before
public void setUp() {
    final DataSource ds = new DriverManagerDataSource(System.getProperty("jdbc.url", "jdbc:sap://localhost:30115"),
            System.getProperty("jdbc.user", "hibernate"), System.getProperty("jdbc.password", "hibernate"));

    final LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(ds);
    builder.setProperty(AvailableSettings.DIALECT,
            System.getProperty("hibernate.dialect", HANAColumnStoreDialect.class.getName()));
    builder.setProperty(AvailableSettings.HBM2DDL_AUTO, "create-drop");
    builder.setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");

    builder.addAnnotatedClass(Employee.class);

    this.sessionFactory = builder.buildSessionFactory();

    final HibernateTemplate ht = new HibernateTemplate();
    ht.setSessionFactory(this.sessionFactory);

    ht.afterPropertiesSet();

    this.template = ht;

    final HibernateTransactionManager txnMgr = new HibernateTransactionManager();
    txnMgr.setDataSource(ds);
    txnMgr.setSessionFactory(this.sessionFactory);
    txnMgr.afterPropertiesSet();

    this.transactionTemplate = new TransactionTemplate(txnMgr);
}
 
开发者ID:aclemons,项目名称:hibernate-hdb-demo,代码行数:32,代码来源:TestEmployee.java

示例2: contribute

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
@Override
public void contribute(final Properties properties, final String provider) {
    if (!provider.equals(HIBERNATE_PROVIDER)) {
        return;
    }
    properties.put(
            AvailableSettings.SCANNER_ARCHIVE_INTERPRETER,
            new TestEEfiArchiveDescriptorFactory()
    );
    // TODO find out why eclipselink allows TX access by default while Hibernate doesn't
    properties.put(
            AvailableSettings.ALLOW_JTA_TRANSACTION_ACCESS,
            true
    );
    properties.put(
            AvailableSettings.JTA_PLATFORM,
            new TestEEfiJtaPlatform(transactionManager(), transactionServices)
    );
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:20,代码来源:PropertyContributor.java

示例3: getInjector

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
@Override
protected Injector getInjector() {
    final Properties persistenceUnitProperties = new Properties();

    persistenceUnitProperties.put(AvailableSettings.JPA_JDBC_URL,
        Utils.getDatabaseUrl(endPointHealthConfiguration.databaseFile()));

    persistenceUnitProperties.put(AvailableSettings.JPA_JDBC_USER,
        endPointHealthConfiguration.databaseUser());

    persistenceUnitProperties.put(AvailableSettings.JPA_JDBC_PASSWORD,
        endPointHealthConfiguration.databasePassword());

    return Guice.createInjector(
        new JpaPersistModule(PERSISTENCE_UNIT).properties(persistenceUnitProperties),
        new EndPointHealthServletModule());
}
 
开发者ID:spypunk,项目名称:endpoint-health,代码行数:18,代码来源:EndPointHealthServletContextListener.java

示例4: buildSessionFactory

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
/**
 * Build the {@code SessionFactory}.
 */
@Override
@SuppressWarnings("deprecation")
public SessionFactory buildSessionFactory() throws HibernateException {
	ClassLoader appClassLoader = (ClassLoader) getProperties().get(AvailableSettings.APP_CLASSLOADER);
	Thread currentThread = Thread.currentThread();
	ClassLoader threadContextClassLoader = currentThread.getContextClassLoader();
	boolean overrideClassLoader =
			(appClassLoader != null && !appClassLoader.equals(threadContextClassLoader));
	if (overrideClassLoader) {
		currentThread.setContextClassLoader(appClassLoader);
	}
	try {
		return super.buildSessionFactory();
	}
	finally {
		if (overrideClassLoader) {
			currentThread.setContextClassLoader(threadContextClassLoader);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:LocalSessionFactoryBuilder.java

示例5: SchemaExport

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
public SchemaExport(ServiceRegistry serviceRegistry, Configuration configuration) {
	this.connectionHelper = new SuppliedConnectionProviderConnectionHelper(
			serviceRegistry.getService( ConnectionProvider.class )
	);
	this.sqlStatementLogger = serviceRegistry.getService( JdbcServices.class ).getSqlStatementLogger();
	this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
	this.sqlExceptionHelper = serviceRegistry.getService( JdbcServices.class ).getSqlExceptionHelper();

	this.importFiles = ConfigurationHelper.getString(
			AvailableSettings.HBM2DDL_IMPORT_FILES,
			configuration.getProperties(),
			DEFAULT_IMPORT_FILE
	);

	final Dialect dialect = serviceRegistry.getService( JdbcServices.class ).getDialect();
	this.dropSQL = configuration.generateDropSchemaScript( dialect );
	this.createSQL = configuration.generateSchemaCreationScript( dialect );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:SchemaExport.java

示例6: registerService

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
@Override
public void registerService(Manageable service, Class<? extends Service> serviceRole) {
	final String domain = service.getManagementDomain() == null
			? AvailableSettings.JMX_DEFAULT_OBJ_NAME_DOMAIN
			: service.getManagementDomain();
	final String serviceType = service.getManagementServiceType() == null
			? service.getClass().getName()
			: service.getManagementServiceType();
	try {
		final ObjectName objectName = new ObjectName(
				String.format(
						OBJ_NAME_TEMPLATE,
						domain,
						sessionFactoryName,
						serviceRole.getName(),
						serviceType
				)
		);
		registerMBean( objectName, service.getManagementBean() );
	}
	catch ( MalformedObjectNameException e ) {
		throw new HibernateException( "Unable to generate service IbjectName", e );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:JmxServiceImpl.java

示例7: createSessionFactoryBean

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
protected LocalSessionFactoryBean createSessionFactoryBean() {

		LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
		factoryBean.setDataSource(this.dataSourceConfig.dataSource());

		if (StringUtil.isEmpty(this.propertiesConfig.hibernateDialect())) {
			throw new IllegalStateException("hibernateDialect is required");
		}

		factoryBean.getHibernateProperties().setProperty(AvailableSettings.DIALECT,
				this.propertiesConfig.hibernateDialect());

		if (!ArrayUtil.isEmpty(this.propertiesConfig.hibernateMappingLocations())) {
			factoryBean
					.setMappingLocations(this.propertiesConfig.hibernateMappingLocations());
		}

		return factoryBean;

	}
 
开发者ID:RJBTechnology,项目名称:rjb-blog-multitenancy,代码行数:21,代码来源:HibernateConfig.java

示例8: testSetJtaTransactionManager

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
@Test
public void testSetJtaTransactionManager() throws Exception {
	DataSource ds = mock(DataSource.class);
	TransactionManager tm = mock(TransactionManager.class);
	UserTransaction ut = mock(UserTransaction.class);
	TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
	JtaTransactionManager jtm = new JtaTransactionManager();
	jtm.setTransactionManager(tm);
	jtm.setUserTransaction(ut);
	jtm.setTransactionSynchronizationRegistry(tsr);
	LocalSessionFactoryBuilder lsfb = new LocalSessionFactoryBuilder(ds);
	lsfb.setJtaTransactionManager(jtm);
	Object jtaPlatform = lsfb.getProperties().get(AvailableSettings.JTA_PLATFORM);
	assertNotNull(jtaPlatform);
	assertSame(tm, jtaPlatform.getClass().getMethod("retrieveTransactionManager").invoke(jtaPlatform));
	assertSame(ut, jtaPlatform.getClass().getMethod("retrieveUserTransaction").invoke(jtaPlatform));
	assertTrue(lsfb.getProperties().get(AvailableSettings.TRANSACTION_STRATEGY) instanceof CMTTransactionFactory);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:HibernateTransactionManagerTests.java

示例9: loadConfiguration

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
/**
 * Create/load a HikariConfig from Hibernate properties.
 *
 * @param props a map of Hibernate properties
 * @return a HikariConfig
 */
@SuppressWarnings("rawtypes")
public static HikariConfig loadConfiguration(Map props)
{
   Properties hikariProps = new Properties();
   copyProperty(AvailableSettings.ISOLATION, props, "transactionIsolation", hikariProps);
   copyProperty(AvailableSettings.AUTOCOMMIT, props, "autoCommit", hikariProps);
   copyProperty(AvailableSettings.DRIVER, props, "driverClassName", hikariProps);
   copyProperty(AvailableSettings.URL, props, "jdbcUrl", hikariProps);
   copyProperty(AvailableSettings.USER, props, "username", hikariProps);
   copyProperty(AvailableSettings.PASS, props, "password", hikariProps);

   for (Object keyo : props.keySet()) {
      String key = (String) keyo;
      if (key.startsWith(CONFIG_PREFIX)) {
         hikariProps.setProperty(key.substring(CONFIG_PREFIX.length()), (String) props.get(key));
      }
   }

   return new HikariConfig(hikariProps);
}
 
开发者ID:openbouquet,项目名称:HikariCP,代码行数:27,代码来源:HikariConfigurationUtil.java

示例10: newFactory

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
private static EntityManagerFactory newFactory(Map<String, String> extraProperties) {
    
    LOGGER.info("Creating EntityManagerFactory...");
    
    try {

        Map<String, String> properties = new HashMap<>();
        properties.putAll(extraProperties);


        if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
            properties.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.GoogleDriver");
            properties.put("javax.persistence.jdbc.url", System.getProperty("cloudsql.url"));
        } else {
            properties.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
            properties.put("javax.persistence.jdbc.url", System.getProperty("cloudsql.url.dev"));
        }

        properties.put(org.hibernate.ejb.AvailableSettings.INTERCEPTOR, TimingInterceptor.class.getName());

        return Persistence.createEntityManagerFactory("Demo", properties);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Failed to create EntityManagerFactory", e);
        throw e;
    }
}
 
开发者ID:bedatadriven,项目名称:appengine-hibernate,代码行数:27,代码来源:Hibernate.java

示例11: findStampByInternalItemUid

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <STAMP_TYPE extends Stamp> STAMP_TYPE findStampByInternalItemUid(String internalItemUid,
        Class<STAMP_TYPE> clazz) {
    try (StatelessSession session = this.openStatelessSession()){

        List<Stamp> stamps = (List<Stamp>) session.createNamedQuery("item.stamps.by.uid")
                .setParameter("uid", internalItemUid)
                .setHint(AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, null)
                .setHint(AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE, null)
                .getResultList();
        for (Stamp stamp : stamps) {
            if (clazz.isInstance(stamp)) {
                return clazz.cast(stamp);
            }
        }
    } catch (HibernateException e) {
        throw SessionFactoryUtils.convertHibernateAccessException(e);
    }
    return null;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:21,代码来源:ItemDaoImpl.java

示例12: getGeneratorDialectFromConnectionDriver

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
private static Class<? extends GeneratorDialect> getGeneratorDialectFromConnectionDriver(
		final Properties settings) {
	final String connectionDriver = settings.getProperty(AvailableSettings.DRIVER);
	if (connectionDriver != null) {
		if (connectionDriver.contains("postgresql")) {
			return PostgresDialect.class;
		}
		if (connectionDriver.contains("mysql")) {
			return MySqlDialect.class;
		}
		if (connectionDriver.contains("sqlserver")) {
			return MsSqlDialect.class;
		}
		if (connectionDriver.contains(".h2.")) {
			return H2Dialect.class;
		}
		if (connectionDriver.contains("oracle")) {
			return OracleDialect.class;
		}
	}
	return null;
}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:23,代码来源:HibernateProvider.java

示例13: getGeneratorDialectFromConnectionUrl

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
private static Class<? extends GeneratorDialect> getGeneratorDialectFromConnectionUrl(final Properties settings) {
	final String connectionUrl = settings.getProperty(AvailableSettings.URL);
	if (connectionUrl != null) {
		if (connectionUrl.contains(":oracle:")) {
			return OracleDialect.class;
		}
		if (connectionUrl.contains(":postgresql:")) {
			return PostgresDialect.class;
		}
		if (connectionUrl.contains(":mysql:")) {
			return MySqlDialect.class;
		}
		if (connectionUrl.contains(":sqlserver:")) {
			return MsSqlDialect.class;
		}
		if (connectionUrl.contains(":h2:")) {
			return H2Dialect.class;
		}
	}
	return null;
}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:22,代码来源:HibernateProvider.java

示例14: getGeneratorDialectFromHibernateDialect

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
private static Class<? extends GeneratorDialect> getGeneratorDialectFromHibernateDialect(
		final Properties settings) {
	final String hibernateDialect = settings.getProperty(AvailableSettings.DIALECT);
	if (hibernateDialect != null) {
		if (hibernateDialect.contains("Oracle")) {
			return OracleDialect.class;
		}
		if (hibernateDialect.contains("PostgreSQL")) {
			return PostgresDialect.class;
		}
		if (hibernateDialect.contains("MySQL")) {
			return MySqlDialect.class;
		}
		if (hibernateDialect.contains("SQLServer")) {
			return MsSqlDialect.class;
		}
		if (hibernateDialect.contains("H2Dialect")) {
			return H2Dialect.class;
		}
	}
	return null;
}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:23,代码来源:HibernateProvider.java

示例15: init

import org.hibernate.cfg.AvailableSettings; //导入依赖的package包/类
public static void init() {
    Map<String, Object> props = new HashMap<String, Object>();
    props.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, true);
    props.put(AvailableSettings.USE_QUERY_CACHE, true);
    props.put(AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, CacheConcurrencyStrategy.NONSTRICT_READ_WRITE);
    props.put(AvailableSettings.CACHE_REGION_FACTORY, Hibernate4MemcachedRegionFactory.class.getName());
    props.put(AvailableSettings.CACHE_REGION_PREFIX, "cachetest");
    props.put(AvailableSettings.CACHE_PROVIDER_CONFIG, "META-INF/h4m-properties.xml");
    props.put(AvailableSettings.HBM2DDL_AUTO, "create");
    props.put(AvailableSettings.USE_STRUCTURED_CACHE, "false");
    props.put(Hibernate4MemcachedRegionFactory.MEMCACHED_ADAPTER_CLASS_PROPERTY_KEY,
            SpyMemcachedAdapter.class.getName());
    props.put(SpyMemcachedAdapter.HOST_PROPERTY_KEY, "localhost:11211");
    props.put(SpyMemcachedAdapter.HASH_ALGORITHM_PROPERTY_KEY, DefaultHashAlgorithm.KETAMA_HASH.name());
    props.put(SpyMemcachedAdapter.OPERATION_TIMEOUT_MILLIS_PROPERTY_KEY, "5000");
    props.put(SpyMemcachedAdapter.TRANSCODER_PROPERTY_KEY, KryoTranscoder.class.getName());
    props.put(SpyMemcachedAdapter.CACHE_KEY_PREFIX_PROPERTY_KEY, "h4m");
    props.put(KryoTranscoder.COMPRESSION_THREASHOLD_PROPERTY_KEY, "20000");

    emf = Persistence.createEntityManagerFactory("cachetest", props);
}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:22,代码来源:EntityTestUtils.java


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