As most of the webpages does not need transaction support, thus I have a marker interface to prevent transaction start and commit for those webpage, which work like follow:
@Override protected void onBeginRequest() { super.onBeginRequest(); if (arg1.getPage() ==null || !(arg1.getPage() instanceof NoTransactionRequired)) try { sqlMap.startTransaction(); } catch (SQLException e) { logger.log("startTransaction fail", e); } } @Override protected void onEndRequest() { super.onEndRequest(); if (arg1.getPage() ==null || !(arg1.getPage() instanceof NoTransactionRequired)) try { sqlMap.commitTransaction(); } catch (Exception e) { logger.log("commitTransaction fail", e); } finally { try { sqlMap.endTransaction(); } catch (SQLException e) { logger.log("endTransaction fail", e); } } } However I found that this is not very reliable and sometime there will have transaction started but haven't get close or no transaction start but try to close the transaction. Anyone know why? By the way, I am thinking about something like private boolean transactionStarted; @Override protected void onBeginRequest() { super.onBeginRequest(); HttpUtil.setNoCacheHeaders((WebResponse) arg2); arg2.setContentType("text/html; charset=UTF-8"); arg2.setCharacterEncoding("UTF-8"); if (arg1.getPage() ==null || !(arg1.getPage() instanceof NoTransactionRequired)) try { sqlMap.startTransaction(); transactionStarted = true; } catch (SQLException e) { logger.log("startTransaction fail", e); } } @Override protected void onEndRequest() { super.onEndRequest(); if (transactionStarted) try { sqlMap.commitTransaction(); } catch (Exception e) { logger.log("commitTransaction fail", e); } finally { try { sqlMap.endTransaction(); } catch (SQLException e) { logger.log("endTransaction fail", e); } } } Do you think this is ok to put a global variable at RequestCycle, is it belong to that session only and for each request it will create a new RequestCycle? ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user