after calling a method, which is working with database (JPA) I am getting warnings:
@Named
public class SomeClass{
@PersistenceContext(unitName = "jpaLayer")
private EntityManager entityManager;
.....
.....
@Transactional
public T save(T entity) {
entityManager.persist(entity);
return entity;
}
}
Managed bean with Transactional annotation and TxType of REQUIRED called outside a transaction context. Beginning a transaction...
But then its generating SQL query and everything is OK.
Info: Hibernate: insert into ALL_USERS_EXMPL (DATE_ADDED, login, password) values (?, ?, ?)
How can I get rid of these warnings?
Use REQUIRES_NEW
instead of REQUIRED
to run it outside a transaction context.
Please refer to docs
you need to have @Transactional(Transactional.TxType.REQUIRES_NEW)