1
使用Java EE我需要使用有状态会话Bean。有状态会话bean忘记值
@Stateful
@TransactionManagement(TransactionManagementType.BEAN)
public class FacadeExercice extends AbstractFacade<EntityBeanExercice>
implements IFacadeExercice {
@PersistenceContext(unitName = "GestionCours-ejbPU")
private EntityManager em;
@Resource
private UserTransaction transaction;
private int lastChange;
private int connections;
[...]
@Override
public EntityBeanExercice find(Object id) {
EntityBeanExercice ex = null;
connections += 5;
try {
transaction.begin();
ex = super.find(id);
lastChange = ex.getLastChange();
transaction.commit();
} catch (Exception ex1) {
Logger.getLogger(FacadeExercice.class.getName()).log(
Level.SEVERE, null, ex1);
}
return ex;
}
}
但每次我在我的豆进入时,connections
变量设置为0。
我不知道我在哪里可以寻找一个解决方案。