$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> // $B%H%i%s%6%/%7%g%s30$N=hM}(B($B%/%i%$%"%s%H$+$iEEJ8<u?.(B)<br> doSomething();<br><br> // $B%H%i%s%6%/%7%g%s3+;O(B<br> userTransaction.begin();<br> try {<br> hogeService.execute();<br> <br> // $B%/%i%$%"%s%H$KEEJ8Aw?.(B<br> doOutput();
<br> <br> // $B%H%i%s%6%/%7%g%s%3%_%C%H(B<br> // $B"((B hogeService$BFb$G(BfooSerivce$B$NNc30$r%-%c%C%A$7$F(BsetRollbackOnly$B$7$F$k(B<br> // $B$+$b$7$l$J$$$,!"(Bcommit()$B$G(BOK$B!)(B<br> userTransaction.commit();<br> <br> } catch(Exception e) {<br> userTransaction.rollback
();<br> }<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 <
<a href="mailto:koichik@improvement.jp">koichik@improvement.jp</a>> 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: Mon, 3 Dec 2007 17:48:55 +0900<br>From: "Mitsutaka Sato" <<a href="mailto:miztaka@gmail.com">miztaka@gmail.com</a>><br>To: <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>> $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>> 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>> $B$H$$$&$3$H$K$J$k$N$G$7$g$&$+!)(B<br><br></div>$B$O$$!%(B<br><br>> $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>> ($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> private FugaService fugaService;<br></div> private UserTransaction userTransaction;<br><div class="Ih2E3d"><br> public void execute() {<br> try {<br> fugaService.execute();<br> } catch (Exception e) {
<br></div> userTransaction.setRollbackOnly();<br> log.info(e);<br> }<br> }<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><component name="koichik">
<br> <property name="fullName">"Koichi Kobayashi"</property><br> <property name="email">"<a href="mailto:koichik@improvement.jp">koichik@improvement.jp</a>"</property>
<br> <property name="blog">"<a href="http://d.hatena.ne.jp/koichik" target="_blank">http://d.hatena.ne.jp/koichik</a>"</property><br></component><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>