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:
Post a Comment