Abhishek,
Sorry that you are running in to this issue.
Thanks for the information. We could replicate the issue at our end and have filed a bug report for the concerned team to make the necessary changes in the tutorial.
You need to make following changes to save the persistence object in the database.
1) Open persistence service layer class (in your case it is PersistenceLayer.java) and add @Transactional to the class.
import org.springframework.transaction.annotation.Transactional;
@Transactional
public class PersistenceLayer {
2) Open applicationContext.xml file and add the following code
<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:context=”http://www.springframework.org/schema/context”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:p=”http://www.springframework.org/schema/p”
xmlns:tx=”http://www.springframework.org/schema/tx”
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd”>
<context:annotation-config/>
<bean id=”transactionManager”
class=”org.springframework.orm.hibernate3.HibernateTransactionManager”>
<property name=”sessionFactory” ref=”hibernateSession” />
</bean>
<tx:annotation-driven transaction-manager=”transactionManager” />
3. Open BusinessLogic.java class and replace the following code instead of BeanFactory definition
ApplicationContext ctx = new ClassPathXmlApplicationContext(“applicationContext.xml”);
PersistenceLayer persistenceLayer = (PersistenceLayer) ctx.getBean(“persistenceLayer”);
Please find the ‘HibernateSpringProject’ file in the attachment for your reference. (Project created based on the tutorial with the above changes)
Sorry for the inconvenience caused. Let us know how it works for you.
Attachments:
You must be
logged in to view attached files.