我创建了PlayPlugin类来管理以这种方式工作的HTTP请求:
public class RequestParamsInjection extends PlayPlugin {
@Override
public boolean rawInvocation(final Http.Request request, Http.Response response) {
// Config is marked with annotation @Entity and works in others context
Config config = Config.find("name=:name").setParameter("name", "requestConfiguration").first();
manageRequest(config);
}
private void manageRequest(Config config) {
// Logic for manage requests that depends on Config in DB, I save you the code
}
}
当我调用一个动作时,插件拦截了请求,并且rawInvocation(...)中断,因为没有活动的EntityManager。给我这个JPAException:
名称[默认]没有活动的EntityManager,事务未启动?
我可能必须在rawInvocation(...)中手动创建事务?有人可以帮我吗?