I'm wondering what would be the most efficient (in terms of needed resources) scope for a repository class in CDI. Imagine the following scenario:
@RequestScoped
//OR @ApplicationScoped OR @SessionScoped OR @ConversationScoped?
public class SomeRepository{
@Inject
private EntityManager em;
public SomeClass getSomeClassById(int id){
return em.createNamedQuery("getSomeClassById",SomeClass.class).
setParameter("id",id).getSingleResult();
}
}
The EntityManager in ths example is produced with a @RequestScoped
scope.