Replies: 1 comment
-
I got around this by using this in my job: import play.api.Play;
public void execute(final JobExecutionContext context) throws JobExecutionException {
JPAApi jpaApi = Play.current().injector().instanceOf(JPAApi.class);
jpaApi.withTransaction(new java.lang.Runnable() {
@Override
public void run() {
Some some = Some.findById2(someId, jpaApi); and then in Some Model: public static Some findById2(Long someId, JPAApi jpaApi) {
return jpaApi.em().find(Some.class, someId);
} We don't love this solution because we had to create a separate method in Some but it works. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am doing an upgrade and on 2.6.6 atm.
Our Quartz scheduled jobs fail when trying to access database using Jpa.
This throws a RuntimeException:
Am I correct in thinking I'll need to create a custom JobFactory that injects JPAApi?
I'm guessing others have come across this but I'm not finding example code.
It's not just one job that needs JPA but every job does some db interaction.
Can anyone share.. either advice or code?
Thanks
Bagus
Beta Was this translation helpful? Give feedback.
All reactions