What can I get from setting this TransactionAttributeType.NOT_SUPPORTED

I happen to find examples that use this construct, although I'm not sure what I can get from this?

Does this mean that all selected stateless statements in EJ should follow this?

@Stateless public class EmployeeFacade { @PersistenceContext(unitName="EmployeeService") EntityManager em; @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<Department> findAllEmployees() { return em.createQuery("SELECT e FROM Employee e", Employee.class) .getResultList(); } 

What will I get from this?

Thanks.

+7
source share
1 answer

What are you getting:

  • A relatively formal way of saying that your method does not require a transaction (as a result, you know, for example, that it will not call persist, merge or remove in the EntityManager).
  • Possible performance optimization in some cases.
    • No need to create / transfer a transaction. According to the Java EE 5 Tutorial : "Since transactions involve overhead, this attribute can improve performance."
    • According to other sources (for example, Pro JPA 2), it offers the possibility of implementation not to create managed objects at all (which, most likely, will be more difficult than creating individual elements at once).
+6
source

All Articles