【问题标题】:@Transactional not working giving exception to add @Transactional@Transactional 不工作给例外添加@Transactional
【发布时间】:2015-02-19 04:56:41
【问题描述】:

我正在使用 jpa 和 Play 2.2.1 java。我有一个方法可以找到所有求职者

我的控制器功能

@Transactional
     public static Result index() {

        return ok(views.html.admin.jobseeker.render("Your new application is ready.", Jobseekers.all()));

    }

和模型方法

public static List<Jobseekers> all() {
        @SuppressWarnings("unchecked")
        List<Jobseekers> el = JPA.em().createQuery("from Jobseekers order by id").getResultList();
        return el;
    }

但是我遇到了异常

[RuntimeException: No EntityManager bound to this thread. Try to annotate your action method with @play.db.jpa.Transactional]

即使我添加了@Transactional,我也不知道为什么会出现此错误

有人可以帮帮我吗?

谢谢

【问题讨论】:

    标签: java jpa orm annotations playframework-2.2


    【解决方案1】:

    正确的注解是@Transactional 而不是@Transaction

    【讨论】:

    • 仍然得到相同的结果
    • 您确定您使用的是正确的@Transactional
    猜你喜欢
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 2013-11-24
    • 2017-06-04
    • 2021-10-30
    • 1970-01-01
    • 2016-12-19
    • 2021-02-02
    相关资源
    最近更新 更多