Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get a quartz job to use a hibernate transaction session  RSS feed

Som Bhattacharyya
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i have run into a implementation issue.
Please review the following scenario ,

i have a testService class that is configured as a Spring bean in application context.
This class is configured as a transaction proxy in the app context and wraps a target java class(defaultservicetarget) that generates quartz jobs depending on inputs received from the user.
The target class(defaultservicetarget) actually can perform the dB calls as it is configured as a transactionproxyfactory bean(testService) in the app context.

So inside a method of the target class(defaultservicetarget) i get a quartz scheduler and generate jobdetails and trigger according to the user choice. The trigger used is a simple trigger. And i schedule a job(delayJob.class) accordingly.

i use a job class(delayJob) created by implementing the job interface. i want to execute some database communication inside the job class for processing and perform some steps according to that.

Now when the target class method(defaultservicetarget) executes and scheduled job(s) are created ie. the control enters the "execute" method of the job class(delayJob) i am no longer able to use the persistence context that was being used by the caller target class and get a "invocation exception".

So basically i need to have the hibernate transaction context inside the "job" class as well so that i can carry out the dB transactions.

i cannot use the concept of spring managed quartz ser vices because i would need to configure the triggers and everything as beans. But i have the trigger intervals that are dynamic and cannot be injected beforehand.

Help will be highly appreciated. i have been stuck with this for three days now.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!