We have experienced a issue that reporting JPAContext has closed in automate testing of bookmark demo project.
Specifically the following endpoint:
@UrlContext("profiles")
public class ProfileService extends ServiceBase {
@GetAction("me")
@PropertySpec("email, roles.name")
public User myProfile() {
return me;
}
}
The logic of rendering me result:
- Generate a RenderJSON object with payload be
me
- Raise
BeforeResultCommit event - captured by JPAPlugin and then close the current JPAContext
me i.e. the User class has a method getRoles() method, which call to AAALookup.roles(roles), in which will result a request to JPADao.findOneBy(...) call
Since the current JPAContext has been closed already, thus the above JPADao.findOneBy call will raise exception complains that JPAContext is not available.
To handle this scenario, i.e. it require JPA database query after BeforeResultCommit event, we need to generate JPAContext for JPA queries.
We have experienced a issue that reporting JPAContext has closed in automate testing of bookmark demo project.
Specifically the following endpoint:
The logic of rendering
meresult:meBeforeResultCommitevent - captured byJPAPluginand then close the currentJPAContextmei.e. theUserclass has a methodgetRoles()method, which call toAAALookup.roles(roles), in which will result a request toJPADao.findOneBy(...)callSince the current
JPAContexthas been closed already, thus the aboveJPADao.findOneBycall will raise exception complains thatJPAContextis not available.To handle this scenario, i.e. it require JPA database query after
BeforeResultCommitevent, we need to generateJPAContextforJPAqueries.