Ejb-3.0 – set this transactionattributetype NOT_ What can supported get

I happened to find an example of using this structure, although I don't know what I can get from it?

Does this mean that all select statements in stateless EJBs should follow this rule?

@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 did I get from it?

thank you.

Solution

What you get is:

> formal way to tell your method that no transactions are required (so you know that it will not call persist, merge or remove in EntityManager). In some cases, performance optimization is possible

>There is no need to create / pass transactions According to Java EE 5 tutorial: "this attribute may improve performance due to transaction overhead." > According to other sources (such as pro JPA 2), it provides the possibility that the implementation does not create managed entities at all (which may be more important than creating separate entities immediately)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>