$B>.NSMM!"$465<x$"$j$,$H$&$4$6$$$^$9!#(B<br>UserTransaction$B$r(BDI$B$9$l$P$h$$$s$G$9$M!*(B<br><br>$B$A$g$C$HH/E8$7$?Nc$r65$($F$$$?$@$-$?$$$N$G$9$,!"(B<br>$B0J2<$N$h$&$K(BHogeService$B$r8F$S=P$9%a%=%C%I$G!"%H%i%s%6%/%7%g%s$N3+;O!A=*N;$r@)8f$7$?$$>l9g!"(B<br><br>=========================<br>private UserTransaction userTransaction;<br>private HogeService hogeService;
<br><br>public void run() {<br><br>&nbsp; // $B%H%i%s%6%/%7%g%s30$N=hM}(B($B%/%i%$%"%s%H$+$iEEJ8<u?.(B)<br>&nbsp; doSomething();<br><br>&nbsp; // $B%H%i%s%6%/%7%g%s3+;O(B<br>&nbsp; userTransaction.begin();<br>&nbsp; try {<br>&nbsp;&nbsp;&nbsp; hogeService.execute();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // $B%/%i%$%"%s%H$KEEJ8Aw?.(B<br>&nbsp;&nbsp;&nbsp; doOutput();
<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // $B%H%i%s%6%/%7%g%s%3%_%C%H(B<br>&nbsp;&nbsp;&nbsp; // $B"((B hogeService$BFb$G(BfooSerivce$B$NNc30$r%-%c%C%A$7$F(BsetRollbackOnly$B$7$F$k(B<br>&nbsp;&nbsp;&nbsp; // $B$+$b$7$l$J$$$,!"(Bcommit()$B$G(BOK$B!)(B<br>&nbsp;&nbsp;&nbsp; userTransaction.commit();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp; } catch(Exception e) {<br>&nbsp;&nbsp;&nbsp; userTransaction.rollback
();<br>&nbsp; }<br>=========================<br><br>$B$3$N$h$&$K=q$/$N$,@5$7$$(B*$B%9%?%$%k(B*$B$G$7$g$&$+!)(B<br><br>$B$A$J$_$K$465<x$$$?$@$/0JA0$O!"(B<br>TransactionManager$B$r(BDI$B$7$F!"(Bbegin()$B$7!"(B<br>$B$=$l$r(BhogeService#execute$B$N0z?t$KEO$7$F$$$^$7$?(B^^;<br><br><br><br><div class="gmail_quote">On Dec 3, 2007 8:00 PM, Koichi Kobayashi &lt;
<a href="mailto:koichik@improvement.jp">koichik@improvement.jp</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">$B>.NS(B (koichik) $B$G$9!%(B
<br><br>Date: &nbsp; &nbsp;Mon, 3 Dec 2007 17:48:55 +0900<br>From: &nbsp; &nbsp;&quot;Mitsutaka Sato&quot; &lt;<a href="mailto:miztaka@gmail.com">miztaka@gmail.com</a>&gt;<br>To: &nbsp; &nbsp; &nbsp;<a href="mailto:seasar-user@ml.seasar.org">seasar-user@ml.seasar.org
</a><br>Subject: [Seasar-user:11885] Transaction$B6-3&$r@_Dj$7$?%3%s%]!<%M%s%H$,3,AXE*$K8F$S=P$5$l$?>l9g(B<br><div class="Ih2E3d"><br>&gt; $B$3$l$O!"(BHogeService#execute$B$,%H%i%s%6%/%7%g%s6-3&$K$J$C$F$$$k$N$G!"(BfugaService$B$G(B<br>&gt; Exception$B$,H/@8$7$F$b!"(BHogeService$B$G(Bcatch$B$7$F$$$k$N$G%H%i%s%6%/%7%g%s$O%3%_%C%H$5$l$k(B
<br>&gt; $B$H$$$&$3$H$K$J$k$N$G$7$g$&$+!)(B<br><br></div>$B$O$$!%(B<br><br>&gt; $B$3$N%1!<%9$G%H%i%s%6%/%7%g%s$,%m!<%k%P%C%/$5$l$k$h$&$JJ}K!$O$J$$$G$7$g$&$+!)(B<br>&gt; ($BLu$"$C$F(BHogeService$BFb$G(BException$B$O%-%c%C%A$7$?$$!#(B)<br><br>HogeService $B$K(B UserTransacstion $B$,(B DI $B$5$l$k$h$&$K(B<br>$B$7$F!$(B<br><div class="Ih2E3d"><br>
Class HogeService {<br><br>&nbsp;private FugaService fugaService;<br></div>&nbsp;private UserTransaction userTransaction;<br><div class="Ih2E3d"><br> &nbsp;public void execute() {<br> &nbsp; &nbsp;try {<br> &nbsp; &nbsp; &nbsp;fugaService.execute();<br> &nbsp; &nbsp;} catch (Exception e) {
<br></div> &nbsp; &nbsp; &nbsp;userTransaction.setRollbackOnly();<br> &nbsp; &nbsp; &nbsp;log.info(e);<br> &nbsp; &nbsp;}<br> &nbsp;}<br><br>}<br><br>$B$H$7$F$/$@$5$$!%(B<br># $B<B:]$K$O(B setRollbackOnly() $B$O(B checked $B$JNc30$r(B<br># $B%9%m!<$9$k$N$G(B try $B!A(B catch $B$,I,MW$K$J$j$^$9!%(B<br><br><br><br>--<br>&lt;component name=&quot;koichik&quot;&gt;
<br> &nbsp; &nbsp;&lt;property name=&quot;fullName&quot;&gt;&quot;Koichi Kobayashi&quot;&lt;/property&gt;<br> &nbsp; &nbsp;&lt;property name=&quot;email&quot;&gt;&quot;<a href="mailto:koichik@improvement.jp">koichik@improvement.jp</a>&quot;&lt;/property&gt;
<br> &nbsp; &nbsp;&lt;property name=&quot;blog&quot;&gt;&quot;<a href="http://d.hatena.ne.jp/koichik" target="_blank">http://d.hatena.ne.jp/koichik</a>&quot;&lt;/property&gt;<br>&lt;/component&gt;<br><br>_______________________________________________
<br>Seasar-user mailing list<br><a href="mailto:Seasar-user@ml.seasar.org">Seasar-user@ml.seasar.org</a><br><a href="https://ml.seasar.org/mailman/listinfo/seasar-user" target="_blank">https://ml.seasar.org/mailman/listinfo/seasar-user
</a><br></blockquote></div><br>