Search in sources :

Example 1 with Session

use of org.hibernate.classic.Session in project intellij-community by JetBrains.

the class HibernateResourceInspection method foo2.

public void foo2() {
    final SessionFactory factory = null;
    final Session session = factory.openSession();
}
Also used : SessionFactory(org.hibernate.SessionFactory) Session(org.hibernate.classic.Session)

Example 2 with Session

use of org.hibernate.classic.Session in project intellij-community by JetBrains.

the class HibernateResourceInspection method foo3.

public void foo3() {
    final SessionFactory factory = null;
    final Session session = factory.openSession();
    session.close();
}
Also used : SessionFactory(org.hibernate.SessionFactory) Session(org.hibernate.classic.Session)

Example 3 with Session

use of org.hibernate.classic.Session in project gocd by gocd.

the class PipelineSqlMapDaoCachingTest method setup.

@Before
public void setup() throws Exception {
    transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    goCache.clear();
    mockTemplate = mock(SqlMapClientTemplate.class);
    repository = mock(MaterialRepository.class);
    environmentVariableDao = mock(EnvironmentVariableDao.class);
    mockSessionFactory = mock(SessionFactory.class);
    repository = mock(MaterialRepository.class);
    transactionTemplate = mock(TransactionTemplate.class);
    configFileDao = mock(GoConfigDao.class);
    pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null, transactionSynchronizationManager, null, configFileDao, mock(Database.class), mockSessionFactory);
    pipelineDao.setSqlMapClientTemplate(mockTemplate);
    session = mock(Session.class);
    when(mockSessionFactory.getCurrentSession()).thenReturn(session);
    when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
Also used : SessionFactory(org.hibernate.SessionFactory) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) TransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TransactionSynchronizationManager) StubGoCache(com.thoughtworks.go.server.service.StubGoCache) SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) Session(org.hibernate.classic.Session) Before(org.junit.Before)

Example 4 with Session

use of org.hibernate.classic.Session in project gocd by gocd.

the class PipelineStateDaoCachingTest method setup.

@Before
public void setup() throws Exception {
    transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    goCache.clear();
    mockTemplate = mock(SqlMapClientTemplate.class);
    repository = mock(MaterialRepository.class);
    environmentVariableDao = mock(EnvironmentVariableDao.class);
    mockSessionFactory = mock(SessionFactory.class);
    repository = mock(MaterialRepository.class);
    transactionTemplate = mock(TransactionTemplate.class);
    configFileDao = mock(GoConfigDao.class);
    pipelineStateDao = new PipelineStateDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null, transactionSynchronizationManager, null, configFileDao, mock(Database.class), mockSessionFactory);
    pipelineStateDao.setSqlMapClientTemplate(mockTemplate);
    session = mock(Session.class);
    when(mockSessionFactory.getCurrentSession()).thenReturn(session);
    when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
Also used : SessionFactory(org.hibernate.SessionFactory) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) TransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TransactionSynchronizationManager) StubGoCache(com.thoughtworks.go.server.service.StubGoCache) SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) Session(org.hibernate.classic.Session) Before(org.junit.Before)

Example 5 with Session

use of org.hibernate.classic.Session in project intellij-community by JetBrains.

the class HibernateResourceInspection method foo5.

public void foo5() {
    SessionFactory factory = null;
    Session session = null;
    try {
        session = factory.openSession();
    } finally {
        session.close();
    }
}
Also used : SessionFactory(org.hibernate.SessionFactory) Session(org.hibernate.classic.Session)

Aggregations

SessionFactory (org.hibernate.SessionFactory)6 Session (org.hibernate.classic.Session)6 StubGoCache (com.thoughtworks.go.server.service.StubGoCache)3 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)3 TransactionTemplate (com.thoughtworks.go.server.transaction.TransactionTemplate)3 Before (org.junit.Before)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2 MaterialRepository (com.thoughtworks.go.server.persistence.MaterialRepository)2 TransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TransactionSynchronizationManager)2 SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)2