有没有办法遍历 Stateful Bean 中所有列出的 EntityManager?
@Stateful
@Local(SomeInterface.class)
public class ContextBean implements SomeInterface{
@PersistenceContext(unitName="00")
private EntityManager em00;
@PersistenceContext(unitName="01")
private EntityManager em01;
...
@PersistenceContext(unitName="0n")
private EntityManager em0n;
public ContextBean() {}
public void test(){
for(EntityManager em : ???){
// Do something
}
}
}
我可以使用循环吗?请问如何使用?