javax.persistence.TransactionRequiredException in small facelet application

后端 未结 3 1460
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 04:07

I\'m trying to persist some values to a MySql database from a small facelet application but keep getting this error. I had this same application with a JPS page and a servle

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 04:40

    Just add @Transactional annotation on your method, e.g.

    @Transactional // <-------------
    public long setSessionState(StateEnum state, String hash) {
    
        QSession s = QSession.session;
        JPAUpdateClause upd = new JPAUpdateClause(em, s);
        upd.set(s.state, state).where(s.hash.eq(hash));
        return upd.execute();
    }
    

提交回复
热议问题