> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>
--
Guillaume Bort, http://guillaume.bort.fr
A JPA error occurred (The JPA context is not initialized. JPA Entity Manager automatically start when one or more classes annotated with the @javax.persistence.Entity annotation are found in the application.):
In a comment by 'bond', I see:
"Correction: @NoTransaction does not prevent transaction, it prevents JPA initialization."
So, that makes sense. @NoTransaction is really intended for controller actions that don't hit the database. If they don't need it, skipping the EM initialization will make things faster.
So, if I use that annotation, it seems I am on my own as far as setting up everything for JPA. Is there a way to trigger initialization? The error implies that it will happen automatically if @Entity classes are found, but that doesn't seem to hold in my case.
How can I initialize JPA explicitly?
Thanks!
@Override
public void before(){
JPAPlugin.startTx(false);
}
@Override
public void after(){
JPAPlugin.closeTx(false);
}
Promise<Meeting> meetingPromise = new Job<Meeting> () {
@Override
public Meeting doJobWithResult() throws Exception {
Meeting meeting = Meeting.findById(id);
while (meeting.bbbMeetingId == null) {
Thread.sleep(1000);
if (JPA.isInsideTransaction()) {
JPAPlugin.closeTx(false);
}
JPAPlugin.startTx(true);
meeting = Meeting.findById(id);
JPAPlugin.closeTx(false);
}
return meeting;
}
}.now();
Meeting meeting = await(meetingPromise);
I am not using the @NoTransaction annotation, because that messes up some other code that checks if the request is coming from a valid user.
Thanks!
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.