Search in sources :

Example 11 with HibernateTransactionManager

use of org.springframework.orm.hibernate5.HibernateTransactionManager in project tutorials by eugenp.

the class PersistenceConfig method hibernateTransactionManager.

@Bean
public PlatformTransactionManager hibernateTransactionManager() {
    final HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory(sessionFactory().getObject());
    return transactionManager;
}
Also used : HibernateTransactionManager(org.springframework.orm.hibernate4.HibernateTransactionManager) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) LocalSessionFactoryBean(org.springframework.orm.hibernate4.LocalSessionFactoryBean)

Example 12 with HibernateTransactionManager

use of org.springframework.orm.hibernate5.HibernateTransactionManager in project trainning by fernandotomasio.

the class TestesDAO method main.

public static void main(String[] args) throws DAOException {
    @SuppressWarnings("resource") ApplicationContext context = new ClassPathXmlApplicationContext("persist-context.xml");
    DAOFactory factory = (DAOFactory) context.getBean("daoFactory");
    NetworkGroupDAO dao = factory.getNetworkGroupDAO();
    SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
    HibernateTransactionManager transactionManager = new HibernateTransactionManager(sessionFactory);
    Session session = transactionManager.getSessionFactory().openSession();
    Transaction tx = session.beginTransaction();
    NetworkGroupDTO group = dao.findRole("OperadorLocal");
    group.getMembers().add("uid=tasdfasd,ou=people");
    dao.update(group);
    tx.commit();
    session.close();
}
Also used : SessionFactory(org.hibernate.SessionFactory) NetworkGroupDTO(com.tomasio.projects.trainning.dto.NetworkGroupDTO) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) HibernateTransactionManager(org.springframework.orm.hibernate4.HibernateTransactionManager) Transaction(org.hibernate.Transaction) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DAOFactory(com.tomasio.projects.trainning.dao.DAOFactory) NetworkGroupDAO(com.tomasio.projects.trainning.dao.NetworkGroupDAO) Session(org.hibernate.Session)

Example 13 with HibernateTransactionManager

use of org.springframework.orm.hibernate5.HibernateTransactionManager in project midpoint by Evolveum.

the class SqlRepositoryBeanConfig method transactionManager.

@Bean
public TransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager htm = new HibernateTransactionManager();
    htm.setSessionFactory(sessionFactory);
    return htm;
}
Also used : HibernateTransactionManager(org.springframework.orm.hibernate5.HibernateTransactionManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 14 with HibernateTransactionManager

use of org.springframework.orm.hibernate5.HibernateTransactionManager in project rhino by PLOS.

the class RhinoConfiguration method transactionManager.

@Bean
// and a JmsTransactionManager.
@Primary
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager manager = new HibernateTransactionManager();
    manager.setSessionFactory(sessionFactory);
    return manager;
}
Also used : HibernateTransactionManager(org.springframework.orm.hibernate3.HibernateTransactionManager) Primary(org.springframework.context.annotation.Primary) AnnotationSessionFactoryBean(org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 15 with HibernateTransactionManager

use of org.springframework.orm.hibernate5.HibernateTransactionManager in project PublicCMS-preview by sanluan.

the class ApplicationConfig method hibernateTransactionManager.

/**
 * Hibernate 事务管理
 *
 * @param sessionFactory
 * @return hibernate transaction manager
 */
@Bean
public HibernateTransactionManager hibernateTransactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager bean = new HibernateTransactionManager();
    bean.setSessionFactory(sessionFactory);
    return bean;
}
Also used : HibernateTransactionManager(org.springframework.orm.hibernate5.HibernateTransactionManager) FactoryBean(org.springframework.beans.factory.FactoryBean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)19 HibernateTransactionManager (org.springframework.orm.hibernate4.HibernateTransactionManager)11 LocalSessionFactoryBean (org.springframework.orm.hibernate4.LocalSessionFactoryBean)10 HibernateTransactionManager (org.springframework.orm.hibernate5.HibernateTransactionManager)6 LocalSessionFactoryBean (org.springframework.orm.hibernate5.LocalSessionFactoryBean)5 HibernateTransactionManager (org.springframework.orm.hibernate3.HibernateTransactionManager)4 Autowired (org.springframework.beans.factory.annotation.Autowired)3 LocalSessionFactoryBean (org.springframework.orm.hibernate3.LocalSessionFactoryBean)2 AnnotationSessionFactoryBean (org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean)2 DAOFactory (com.tomasio.projects.trainning.dao.DAOFactory)1 NetworkGroupDAO (com.tomasio.projects.trainning.dao.NetworkGroupDAO)1 NetworkGroupDTO (com.tomasio.projects.trainning.dto.NetworkGroupDTO)1 Session (org.hibernate.Session)1 SessionFactory (org.hibernate.SessionFactory)1 Transaction (org.hibernate.Transaction)1 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)1 JobExplorerFactoryBean (org.springframework.batch.core.explore.support.JobExplorerFactoryBean)1 JobRepositoryFactoryBean (org.springframework.batch.core.repository.support.JobRepositoryFactoryBean)1 FactoryBean (org.springframework.beans.factory.FactoryBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1