Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
greenlaw110 opened this issue Apr 18, 2019 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@greenlaw110
Copy link
Contributor

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.

@greenlaw110 greenlaw110 added the bug Something isn't working label Apr 18, 2019
@greenlaw110 greenlaw110 self-assigned this Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant