Hello friends, I am having some problem with configuring transaction with spring having Hibernate as the orm tool. My configurations are as follows...
spring-transaction.xml
spring-persistance.xmlCode:<tx:annotation-driven transaction-manager="txManager"/> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean>
Code:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="packagesToScan" value="com.ajaaxx.entities"/> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> <prop key="hibernate.current_session_context_class">jta</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.connection.autocommit">false</prop> <prop key="hibernate.jdbc.batch_size">0</prop> <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop> </props> </property> </bean>
Now in my repository I am doing this:
Now I am having an exception at the time of callingCode:@Repository("repository") @Transactional public class AddCustomerRepositoryImpl implements AddCustomerRepository { Logger logger = Logger.getLogger(getClass()); @Autowired private SessionFactory sessionFactory; private Session currentSession(){ Session session = sessionFactory.getCurrentSession(); logger.debug("Returning a new session in AddCustomerRepositoryImpl."); return session; } @Override @Transactional(propagation=Propagation.REQUIRED,readOnly=false) public String addCustomer(KYC_Customer customer, List<KYC_Document> documents) { logger.debug("Add customer initiated in AddCustomerRepositoryImpl. Customer to add : ["+customer+"]"); try{ Session session = currentSession(); session.beginTransaction(); session.save(customer); for(KYC_Document doc:documents){ System.out.println("SAVING IN SESSION DOCUMENT : ["+doc+"]"); session.save(doc); } //session.getTransaction().commit(); } catch(HibernateException he){ he.printStackTrace(); return REPOSITORY_RETURN_TYPES.EXCEPTION.toString(); } return REPOSITORY_RETURN_TYPES.SUCCESS.toString(); }}
the exception is :Code:sessionfactory.getCurrentSession()
Code:org.hibernate.HibernateException: No TransactionManagerLookup specified at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:81) at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574) at com.ajaaxx.repository.impl.AddCustomerRepositoryImpl.currentSession(AddCustomerRepositoryImpl.java:39) at com.ajaaxx.repository.impl.AddCustomerRepositoryImpl.getServiceTypes(AddCustomerRepositoryImpl.java:93) at com.ajaaxx.service.impl.AddCustomerServiceImpl.getServiceTypes(AddCustomerServiceImpl.java:37) at com.ajaaxx.controllers.GeneratereportController.showForm(GeneratereportController.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) .....
Where do I need to configure the TransactionManagerLookup.. Please help


Reply With Quote
