javax.persistence.TransactionRequiredException: no transaction is in progress

javax.persistence.TransactionRequiredException: no transaction is in progress


I resolved this issue as follows

    @Transactional(readOnly = false)
    public void updateTimeStamp (Long id, long timeStamp) {
       Alert rec = Alert .findById(id);
        try {
            if (!Alert .em().getTransaction().isActive()) {
            Alert .em().getTransaction().begin();
            }
            rec.setTimeStamp(timeStamp);;
            rec.save();
            Alert .em().getTransaction().commit();
        } catch (Exception e) {
            Logger.error(e, "Error: ");
        }
    }


Hope this helps :)

No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days