• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

TransactionRequiredException - Help required !!!

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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:
<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
}
}
</CODE>

Configuration File :
<CODE>
<beans>

<!--=========== 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="***" />
</bean>

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

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

<!-- AOP Based TRANSACTION MANAGEMENT -->

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

</beans></CODE>

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
Ravi
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i'm too.
can you help weeee!
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic