Detecting if there is an open transaction somewhere in the application is needed in a lot of cases. Below is the code I have used to detect a dirty transaction in my Fusion Web Application and ROLLBACK if dirty is true.
try {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
BindingContext bctx = DCUtil.getBindingContext(request);
DCDataControl dc = bctx.findDataControl(“MyAppModuleDataControl”);
MyAppModuleImpl am = (MyAppModuleImpl )dc.getDataProvider();
if (am.getTransaction().isDirty()) {
am.getTransaction().rollback();
}
} catch (Exception e) {
e.printStackTrace();
}