Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Better guidance for dealing with JPA transactions #6489

@gmethvin

Description

@gmethvin

Reading through the JPA documentation, I don't think we're providing the right guidance in terms of how to execute blocking database calls. It should be very clear that you usually do not want to execute blocking calls in the default execution context.

Also, It seems to me that the @Transactional annotation is broken, since you end up running blocking database calls on Play's default execution context, and we strongly suggest that as the way to do it. We could fix this, but the execution context needs to come from somewhere: either Play needs to be responsible for creating it or the user needs to bind it.

If we decide to require a separate execution context, we could also provide an async JPA API, where methods like withTransaction should return CompletionStage<T> and automatically run the transaction in a separate execution context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions