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


Java SingleDataSourceLookup类代码示例

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


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

示例1: setDataSource

import org.springframework.jdbc.datasource.lookup.SingleDataSourceLookup; //导入依赖的package包/类
/**
 * Specify the JDBC DataSource that the JPA persistence provider is supposed
 * to use for accessing the database. This is an alternative to keeping the
 * JDBC configuration in {@code persistence.xml}, passing in a Spring-managed
 * DataSource instead.
 * <p>In JPA speak, a DataSource passed in here will be used as "nonJtaDataSource"
 * on the PersistenceUnitInfo passed to the PersistenceProvider, as well as
 * overriding data source configuration in {@code persistence.xml} (if any).
 * Note that this variant typically works for JTA transaction management as well;
 * if it does not, consider using the explicit {@link #setJtaDataSource} instead.
 * <p><b>NOTE: Only applied if no external PersistenceUnitManager specified.</b>
 * @see javax.persistence.spi.PersistenceUnitInfo#getNonJtaDataSource()
 * @see #setPersistenceUnitManager
 */
public void setDataSource(DataSource dataSource) {
	this.internalPersistenceUnitManager.setDataSourceLookup(new SingleDataSourceLookup(dataSource));
	this.internalPersistenceUnitManager.setDefaultDataSource(dataSource);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:LocalContainerEntityManagerFactoryBean.java

示例2: setJtaDataSource

import org.springframework.jdbc.datasource.lookup.SingleDataSourceLookup; //导入依赖的package包/类
/**
 * Specify the JDBC DataSource that the JPA persistence provider is supposed
 * to use for accessing the database. This is an alternative to keeping the
 * JDBC configuration in {@code persistence.xml}, passing in a Spring-managed
 * DataSource instead.
 * <p>In JPA speak, a DataSource passed in here will be used as "jtaDataSource"
 * on the PersistenceUnitInfo passed to the PersistenceProvider, as well as
 * overriding data source configuration in {@code persistence.xml} (if any).
 * <p><b>NOTE: Only applied if no external PersistenceUnitManager specified.</b>
 * @see javax.persistence.spi.PersistenceUnitInfo#getJtaDataSource()
 * @see #setPersistenceUnitManager
 */
public void setJtaDataSource(DataSource jtaDataSource) {
	this.internalPersistenceUnitManager.setDataSourceLookup(new SingleDataSourceLookup(jtaDataSource));
	this.internalPersistenceUnitManager.setDefaultJtaDataSource(jtaDataSource);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:LocalContainerEntityManagerFactoryBean.java


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