Skip to content

Make it able to create JPAContext when no one available for query #44

@greenlaw110

Description

@greenlaw110

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:

  1. Generate a RenderJSON object with payload be me
  2. Raise BeforeResultCommit event - captured by JPAPlugin and then close the current JPAContext
  3. 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions