开发者

Meaning of @PersistenceContext in JSF 1.2 Managed Beans

JSF 1.2 specification allows injection of an entity manager into a managed bean via the @PersistenceContext annotation (JSR 252, 开发者_StackOverflow中文版p. 5-13).

What is the semantics of such an entity manager regarding transactions and lifecycle?

Is an EAR-scoped JTA-style persistence unit supposed to work here?


@Stateless
public class YourServiceBean implements YourService {
    @PersistenceContext(unitName="YourServicePU")
    EntityManager em;
    // ...
}

This will inject an EntityManager instance that you do not have to dispose of (the container takes care of it) and is supposed to play nice with container-managed transactions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜