本文整理汇总了Java中org.springframework.orm.hibernate3.SessionHolder.getSession方法的典型用法代码示例。如果您正苦于以下问题:Java SessionHolder.getSession方法的具体用法?Java SessionHolder.getSession怎么用?Java SessionHolder.getSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.hibernate3.SessionHolder
的用法示例。
在下文中一共展示了SessionHolder.getSession方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openReadOnlyConnection
import org.springframework.orm.hibernate3.SessionHolder; //导入方法依赖的package包/类
private void openReadOnlyConnection(final HttpServletRequest request) {
if (noTransaction(request)) {
return;
}
logDebug(request, "Opening read-only transaction for include");
final Connection connection = (Connection) TransactionSynchronizationManager.getResource(connectionProvider);
final SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
final Session session = holder.getSession();
session.setFlushMode(FlushMode.MANUAL);
session.setDefaultReadOnly(true);
session.reconnect(connection);
TransactionSynchronizationManager.setCurrentTransactionReadOnly(true);
}
示例2: doGetActivePersistenceContext
import org.springframework.orm.hibernate3.SessionHolder; //导入方法依赖的package包/类
@Override
protected Session doGetActivePersistenceContext(Object testObject) {
SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(getPersistenceUnit(testObject));
if (sessionHolder != null && sessionHolder.getSession() != null && sessionHolder.getSession().isOpen()) {
return sessionHolder.getSession();
}
return null;
}
示例3: tearDown
import org.springframework.orm.hibernate3.SessionHolder; //导入方法依赖的package包/类
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
if (sessionOwner && session != null) {
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
Session s = holder.getSession();
s.flush();
TransactionSynchronizationManager.unbindResource(sessionFactory);
SessionFactoryUtils.closeSession(s);
}
if (wiser != null) {
wiser.stop();
}
}
示例4: tearDown
import org.springframework.orm.hibernate3.SessionHolder; //导入方法依赖的package包/类
public void tearDown()
throws Exception
{
SessionFactory sf = (SessionFactory) this.context.getBean("sessionFactory");
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
Session s = holder.getSession();
s.flush();
TransactionSynchronizationManager.unbindResource(sf);
//SessionFactoryUtils.closeSessionIfNecessary(s, sf);
SessionFactoryUtils.releaseSession(s, sf);
}
示例5: getSession
import org.springframework.orm.hibernate3.SessionHolder; //导入方法依赖的package包/类
public Session getSession()
{
SessionFactory sf = (SessionFactory) this.context.getBean("sessionFactory");
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
return holder.getSession();
}