亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

hibernate 報錯 nested transactions not supported

hibernate 報錯 nested transactions not supported

Bangk 2016-08-29 11:23:33
頁面代碼如下????<div?id="a"?class="panel-collapse?collapse?in"?role="tabpanel"?aria-labelledby="headingOne"> ??????<a?href="<%=path?%>/project/Project_query.action"?target="add"?class="list-group-item">所有項目</a> ?<button?type="button"?class="?list-group-item"?data-toggle="modal"?data-target="#myModal">創建項目</button> ??? ??? ???<div?class="modal?fade"?id="myModal"?tabindex="-1"?role="dialog"?aria-labelledby="myModalLabel"> ??<div?class="modal-dialog"?role="document"> ????<div?class="modal-content"> ??????<div?class="modal-header"> ????????<button?type="button"?class="close"?data-dismiss="modal"?aria-label="Close"><span?aria-hidden="true">&times;</span></button> ????????<h4?class="modal-title"?id="myModalLabel">Modal?title</h4> ??????</div> ??????<div?class="modal-body"> ????????<iframe?name="added"?src="jsp/project_added.jsp"?height="29%"?width="100%"?frameborder="0"?style="background-color:?#ccc"></iframe> ??????</div> ????</div> ??</div> </div> ??? ???<a?href="#"?class="list-group-item">修改項目</a> ???<a?href="#"?class="list-group-item">移除項目</a> ???<a?href="#"?class="list-group-item">演示項目</a> ???<a?href="#"?class="list-group-item">移交項目</a> ????</div> ??</body> <script?type="text/javascript"?src="js/jquery.js"></script> <script?type="text/javascript"?src="js/bootstrap.js"></script> ??<script> ???$(document).ready(function()?{ ?var?AdminName=document.referrer; ????if(AdminName==""){ ?????alert("非法訪問!"); ?????window.location.href="login.jsp";?? ?}; }); $('#myModal').on('shown.bs.modal',?function?()?{ ??$('#myInput').focus() }) ??</script> </html>框架內頁面代碼如下 <body?style="-moz-user-select:none;-webkit-user-select:none;"> ?<div?align="center"> ???<div?style="margin-bottom:?5px;"?class="jumbotron"> ????<h2>全部項目<a?title="刷新"?onclick="refresh()"><span?class="glyphicon?glyphicon-refresh"?aria-hidden="true"></span></a></h2> ???</div> ??<div?style="margin-top:?0px;margin-left:?15px;margin-right:?15px;"?class="panel?panel-success"> ???<!--?Default?panel?contents?--> ???<div?class="panel-heading">項目列表</div> ???<table?class="table"> ????<tr?align="center"> ?????<td>項目編號</td> ?????<td>項目名稱</td> ?????<td>項目備注</td> ?????<td>項目狀態</td> ?????<td>項目操作</td> ????</tr> ????<s:iterator?value="#session.project_list"?var="pro"> ????<tr?align="center"> ?????<td><s:property?value="#pro.ProjectId"/></td> ?????<td><a?target=_blank?href="<s:property?value="#pro.ProjectUrl"/>"><s:property?value="#pro.ProjectName"/></a></td> ?????<td><s:property?value="#pro.ProjectRemark"/></td> ?????<td><span?class="glyphicon?<s:property?value="#pro.ProjectCondition"/>"?aria-hidden="true"></span></td> ?????<td><a?target=_blank?title="查看項目"?href="<s:property?value="#pro.ProjectUrl"/>"><span?class="glyphicon?glyphicon-eye-open"?aria-hidden="true"></span></a>?<a?title="修改項目"><span?class="glyphicon?glyphicon-pencil"?aria-hidden="true"></span></a>?<a?href="<%=path%>/project/Project_delete.action?pid=<s:property?value="#pro.ProjectId"/>"?title="刪除項目"??onclick="javascript:return?confirm('確認刪除?');"?><span?class="glyphicon?glyphicon-trash"?aria-hidden="true"></span></a></td> ????</tr> ????</s:iterator> ???</table> ??</div> ??<h5>Copyright???2016?Kaiser.zsk?All?Rights?Reserved</h5> ?</div> </body> <script?type="text/javascript"?src="./js/jquery.js"></script> <script?type="text/javascript"?src="./js/bootstrap.js"></script> <script?type="text/javascript"> $(document).ready(function()?{ ????$(".1").addClass("glyphicon-ok"); ?$(".0").addClass("glyphicon-remove"); }); function?refresh(){? ????window.location.reload();//刷新當前頁面.? ??//或者下方刷新方法? ??//parent.location.reload()刷新父親對象(用于框架)--需在iframe框架內使用? ??//?opener.location.reload()刷新父窗口對象(用于單開窗口? ??//top.location.reload()刷新最頂端對象(用于多開窗口)? } </script> </html>后端代碼如下 ?/** ??*?項目查看接口 ??*?@return?項目實體模型組 ??*/ ?public?List<Project>?ProjectExamine()?{ ??Transaction?tx?=?null; ??List<Project>?list=?null; ??String?hql=""; ??try?{ ???Session?session?=?DaraBaseSessionFactory.getSessionFactory().getCurrentSession(); ???tx?=?session.beginTransaction(); ???hql?=?"from?Project"; ???Query?query?=?session.createQuery(hql); ???list?=?query.list(); ???tx.commit(); ???return?list; ??}?catch?(Exception?e)?{ ???e.printStackTrace(); ???tx.commit(); ???return?list; ??}finally{ ???if?(tx!=null)?{ ????tx?=?null; ???} ??} ?} }配置文件如下<package?name="project"?namespace="/project"?extends="default"> ??<action?name="*_*"?class="com.Action.{1}Action"?method="{2}"> ???<result?name="query_success">/jsp/project_query.jsp</result> ???<result?name="delete_success"?type="chain">Project_query</result> ???<result?name="added_success">/jsp/project_added_ok.jsp</result> ???<result?name="added_failure">/jsp/project_added_no.jsp</result> ???<result?name="added_over">/jsp/project_added_over.jsp</result> ??</action> ?</package>以上為實現報錯頁面所需代碼!為什么會報錯說 我事件嵌套了??我每個動作的事件都提交了啊!?。?
查看完整描述

5 回答

已采納
?
yanrun

TA貢獻317條經驗 獲得超240個贊

網上看的解決辦法

tx?=?getSession().beginTransaction();

改成

?tx?=?getSession().beginTransaction().begin();

查看完整回答
反對 回復 2016-08-29
  • Bangk
    Bangk
    實際上這個對我沒用,但還是采納了,別人或許會用到,我修改了Hibernate框架源碼,把嵌套事件警告沉默了,哈哈哈,數據就有了
  • yanrun
    yanrun
    厲害啊
  • Bangk
    Bangk
    沒什么用虛擬機的注解禁止了Hibernate的事務類輸出異常
點擊展開后面1
?
weibo_那是什么叨_03580699

TA貢獻14條經驗 獲得超5個贊

需要的進行回滾,不需要的就不使用事務

查看完整回答
反對 回復 2016-08-29
?
weibo_那是什么叨_03580699

TA貢獻14條經驗 獲得超5個贊

定義事務傳播行為?? 遇到異常全部回滾

查看完整回答
反對 回復 2016-08-29
?
摩訶迦葉

TA貢獻146條經驗 獲得超54個贊


finally{

?? if?(tx!=null)?{

??? tx.close();

????tx?=?null;

???}

session.close();

}

查看完整回答
反對 回復 2016-08-29
  • Bangk
    Bangk
    你在逗我???Transaction 沒有close這個方法
  • 摩訶迦葉
    摩訶迦葉
    哦,忘了。 那你也沒關閉session啊
  • 5 回答
  • 0 關注
  • 2804 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號