本文整理汇总了Java中org.springframework.orm.hibernate5.HibernateTemplate类的典型用法代码示例。如果您正苦于以下问题:Java HibernateTemplate类的具体用法?Java HibernateTemplate怎么用?Java HibernateTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HibernateTemplate类属于org.springframework.orm.hibernate5包,在下文中一共展示了HibernateTemplate类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的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: hibernateTemplate
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的package包/类
@Bean
public HibernateTemplate hibernateTemplate(SessionFactory sessionFactory) {
return new HibernateTemplate(sessionFactory);
}
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:HiberConfig.java
示例3: getHibernateTemplate
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的package包/类
public HibernateTemplate getHibernateTemplate() {
return hibernateTemplate;
}
开发者ID:bejondshao,项目名称:personal,代码行数:4,代码来源:UserDAOImpl.java
示例4: setHibernateTemplate
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的package包/类
@Resource
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
开发者ID:bejondshao,项目名称:personal,代码行数:5,代码来源:UserDAOImpl.java
示例5: getHibernateTemplate
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTemplate getHibernateTemplate(SessionFactory sessionFactory) {
HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
return hibernateTemplate;
}
开发者ID:sylvainleroux,项目名称:bank,代码行数:7,代码来源:BankConfig.java
示例6: createHibernateTemplate
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的package包/类
/**
* Create a HibernateTemplate for the given SessionFactory.
* Only invoked if populating the DAO with a SessionFactory reference!
* <p>Can be overridden in subclasses to provide a HibernateTemplate instance
* with different configuration, or a custom HibernateTemplate subclass.
* @param sessionFactory the Hibernate SessionFactory to create a HibernateTemplate for
* @return the new HibernateTemplate instance
* @see #setSessionFactory
*/
protected HibernateTemplate createHibernateTemplate(SessionFactory sessionFactory) {
return new HibernateTemplate(sessionFactory);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:HibernateDaoSupport.java
示例7: setHibernateTemplate
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的package包/类
/**
* Set the HibernateTemplate for this DAO explicitly,
* as an alternative to specifying a SessionFactory.
* @see #setSessionFactory
*/
public final void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:HibernateDaoSupport.java
示例8: getHibernateTemplate
import org.springframework.orm.hibernate5.HibernateTemplate; //导入依赖的package包/类
/**
* Return the HibernateTemplate for this DAO,
* pre-initialized with the SessionFactory or set explicitly.
* <p><b>Note: The returned HibernateTemplate is a shared instance.</b>
* You may introspect its configuration, but not modify the configuration
* (other than from within an {@link #initDao} implementation).
* Consider creating a custom HibernateTemplate instance via
* {@code new HibernateTemplate(getSessionFactory())}, in which case
* you're allowed to customize the settings on the resulting instance.
*/
public final HibernateTemplate getHibernateTemplate() {
return this.hibernateTemplate;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:HibernateDaoSupport.java
注:本文中的org.springframework.orm.hibernate5.HibernateTemplate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论