• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring - JPA/Hibernate @Schedular and @Transactional

 
Ranch Hand
Posts: 138
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using Spring and JPA/Hibernate for my project.
I am writing a job using spring @Schedular mechanism.
I am facing very strange issue here, not able to update the DB values within transaction. I am using @Transactional annotation.

Is there anything which I am missing? The job is getting called, able to read the data but not able to update the DB values.

Any idea?


Thanks,
Atul
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

You will need to add below writed code into context.xml

<tx:annotation-driven transaction-manager="transactionManager" />


and  configure entity manager with below bean

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>


afterwards, you are suppose to use below cited lines for service creation in class boundry

@Service
@EnableTransactionManagement
public class Service {

//method
@Transactional(propagation = Propagation.REQUIRED)
public void save(Entity entity) {

       .
       .
       .
       }



}

 
Atul More
Ranch Hand
Posts: 138
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Its too late to answer this post.  
I solved the issue, I used @Configuration annotation in schedular class instead of it I have to use @Service annotation.
The problem was solved..

Thanks,
Atul
reply
    Bookmark Topic Watch Topic
  • New Topic