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