File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes TransactionRequiredException - Help required !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "TransactionRequiredException - Help required !!!" Watch "TransactionRequiredException - Help required !!!" New topic

TransactionRequiredException - Help required !!!

Ravindran Loganathan

Joined: May 25, 2005
Posts: 1

I am trying to update data. I use the JpaDaoSupport (Spring) based POJO as the DAO layer. HSQL is the back-end. Declarative Transaction Management is used. I have a search & update functionalities. Out of these, search is working fine. whereas update method is throwing javax.persistence.TransactionRequiredException: Executing an update/delete query

Source Code:
public class SimpleEmployeeViewBuilder extends JpaDaoSupport implements EmployeeViewBuilder {

// Search Methods & Other declarations

@Transactional(propagation = Propagation.REQUIRED)
public void updateEmployeeView(final SimpleEmployeeView view) {

EntityManager anEntityManager = getJpaTemplate().getEntityManagerFactory().createEntityManager();

final Query query = anEntityManager.createQuery(
"UPDATE employee.pd.Employee emp SET emp.employeeName=? WHERE emp.employeeId =?");

query.setParameter(1, view.getEmployeeName());
query.setParameter(2, view.getEmployeeId());

query.executeUpdate(); //****This is the line throwing exception

Configuration File :

<!--=========== Datasources ===========-->
<bean id="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url"
value="jdbc:hsqldb:file:test/hsqldb/data;shutdown=true" />
<property name="username" value="***" />
<property name="password" value="***" />

<!--=========== EntityManagerFactory ===========-->
<bean id="entityManagerFactory"class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="false" />

<bean id="employeeViewBuilder"class="employee.viewobject.SimpleEmployeeViewBuilder">
<property name="entityManagerFactory">
<ref bean="entityManagerFactory" />


<tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
<bean id="txManager"
<property name="entityManagerFactory"
ref="entityManagerFactory" />
<property name="dataSource" ref="dataSource" />


And, this is the exception stack trace:

I am struggling with this problem for couple of days but no progress....
If any body resolved the same problem or you could able to identify the issue please do post your suggestions.

Thanks in advance
hung kin

Joined: Nov 18, 2008
Posts: 6
i'm too.
can you help weeee!
I agree. Here's the link:
subject: TransactionRequiredException - Help required !!!
It's not a secret anymore!