I\'m getting the following exception when trying to use my @Service annotated classes:
org.hibernate.HibernateException: Could not obtain transa
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory)
{
HibernateTransactionManager htm = new HibernateTransactionManager();
htm.setTransactionSynchronization(HibernateTransactionManager.SYNCHRONIZATION_ALWAYS);
htm.setDataSource(dataSource());
htm.setSessionFactory(sessionFactory);
return htm;
}
You just need to add
-------------------------------
htm.setTransactionSynchronization(HibernateTransactionManager.SYNCHRONIZATION_ALWAYS);
-------------------------------
I used dependencies
-----------------------------------
org.hibernate
hibernate-core
5.2.2.Final
org.springframework
spring-web
5.0.1.RELEASE