本文整理匯總了Java中org.hibernate.service.ServiceRegistryBuilder.addService方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceRegistryBuilder.addService方法的具體用法?Java ServiceRegistryBuilder.addService怎麽用?Java ServiceRegistryBuilder.addService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.service.ServiceRegistryBuilder
的用法示例。
在下文中一共展示了ServiceRegistryBuilder.addService方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSessionFactory
import org.hibernate.service.ServiceRegistryBuilder; //導入方法依賴的package包/類
/**
* Configuration of session factory with Fabric integration.
*/
public static SessionFactory createSessionFactory(String fabricUrl, String username, String password, String fabricUser, String fabricPassword)
throws Exception {
// creating this here allows passing needed params to the constructor
FabricMultiTenantConnectionProvider connProvider = new FabricMultiTenantConnectionProvider(fabricUrl, "employees", "employees", username, password,
fabricUser, fabricPassword);
ServiceRegistryBuilder srb = new ServiceRegistryBuilder();
srb.addService(org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider.class, connProvider);
srb.applySetting("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect");
Configuration config = new Configuration();
config.setProperty("hibernate.multiTenancy", "DATABASE");
config.addResource("com/mysql/fabric/demo/employee.hbm.xml");
return config.buildSessionFactory(srb.buildServiceRegistry());
}
示例2: createSessionFactory
import org.hibernate.service.ServiceRegistryBuilder; //導入方法依賴的package包/類
/**
* Configuration of session factory with Fabric integration.
*/
public static SessionFactory createSessionFactory(String fabricUrl, String username, String password, String fabricUser, String fabricPassword) throws Exception {
// creating this here allows passing needed params to the constructor
FabricMultiTenantConnectionProvider connProvider = new FabricMultiTenantConnectionProvider(fabricUrl, "employees", "employees", username, password, fabricUser, fabricPassword);
ServiceRegistryBuilder srb = new ServiceRegistryBuilder();
srb.addService(org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider.class, connProvider);
srb.applySetting("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect");
Configuration config = new Configuration();
config.setProperty("hibernate.multiTenancy", "DATABASE");
config.addResource("com/mysql/fabric/demo/employee.hbm.xml");
return config.buildSessionFactory(srb.buildServiceRegistry());
}
示例3: registryBuilder
import org.hibernate.service.ServiceRegistryBuilder; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Nullable @Override protected ServiceRegistryBuilder registryBuilder() {
ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();
BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.
dataSrc.setTransactionManager(jotm.getTransactionManager());
dataSrc.setDefaultAutoCommit(false);
JdbcDataSource h2DataSrc = new JdbcDataSource();
h2DataSrc.setURL(CONNECTION_URL);
dataSrc.setXaDataSourceInstance(h2DataSrc);
connProvider.setDataSource(dataSrc);
connProvider.configure(Collections.emptyMap());
builder.addService(ConnectionProvider.class, connProvider);
builder.addService(JtaPlatform.class, new TestJtaPlatform());
builder.addService(TransactionFactory.class, new JtaTransactionFactory());
return builder;
}