<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>ueblog &#187; DBFlute</title>
	<atom:link href="http://ueblog.natural-wave.com/tag/dbflute/feed/" rel="self" type="application/rss+xml" />
	<link>http://ueblog.natural-wave.com</link>
	<description>Web関連のネタを中心に役立つ情報を配信しています。</description>
	<lastBuildDate>Wed, 11 Jan 2012 00:51:56 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/tag/dbflute/feed/" />
		<item>
		<title>Teeda + DBFlute環境でバッチ作成</title>
		<link>http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 14:35:48 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[DBFlute]]></category>
		<category><![CDATA[Teeda]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/</guid>
		<description><![CDATA[現在、Teeda + DBFluteな環境で、Webアプリを製作中なわけですが、DBを更新する処理とかのバッチ作成する時って、どこにソースを配置すべきなんでしょう。 考えた末、、Webアプリと混在する環境に置く事に。 javaのソースディレクトリにbatchっていうのを]]></description>
			<content:encoded><![CDATA[<p>現在、Teeda + DBFluteな環境で、Webアプリを製作中なわけですが、DBを更新する処理とかのバッチ作成する時って、どこにソースを配置すべきなんでしょう。</p>
<p>考えた末、、Webアプリと混在する環境に置く事に。</p>
<p><a href='http://ueblog.natural-wave.com/wp-content/uploads/2007/12/home.jpg' title='teeda-batch' rel="lightbox"><img src='http://ueblog.natural-wave.com/wp-content/uploads/2007/12/home.thumbnail.jpg' alt='teeda-batch' /></a></p>
<p>javaのソースディレクトリにbatchっていうのを作って、そこにmain関数を書いてしまう。<br />
そして、ソースはこんな感じで。<br />
<br clear="all"/></p>
<div class="igBar"><span id="ljava-2"><a href="#" onclick="javascript:showPlainTxt('java-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-2">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.framework.container.S2Container;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.framework.container.factory.S2ContainerFactory;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import sample.dbflute.exbhv.MemberBhv;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import sample.dbflute.exentity.Member;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> S2PATH = <span style="color: #ff0000;">"dbflute.dicon"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; S2Container container = S2ContainerFactory.<span style="color: #006600;">create</span><span style="color: #66cc66;">&#40;</span>S2PATH<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; container.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MemberBhv memberBhv</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span style="color: #66cc66;">&#40;</span>memberBhv<span style="color: #66cc66;">&#41;</span>container.<span style="color: #006600;">getComponent</span><span style="color: #66cc66;">&#40;</span>MemberBhv.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AMember+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Member</span></a> member = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AMember+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Member</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; member.<span style="color: #006600;">setId</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; member.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"name"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memberBhv.<span style="color: #006600;">insert</span><span style="color: #66cc66;">&#40;</span>member<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; container.<span style="color: #006600;">destroy</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
S2Containerを呼び出し、Behaviorを作成。Behaviorを通して簡単なinsert処理を。<br />
これで完了。</p>
<p>いちおう、Container経由でWebで作ったロジックもちゃんと呼べたりもしますし、DBFluteの便利なBehaviorやConditionBeanも呼び出せるので、これでええかなと。</p>
<p>しかし、調べてみるといろいろ意見があったりしてます。<br />
<a href="https://ml.seasar.org/archives/seasar-user/2007-August/011996.html" target="_blank">https://ml.seasar.org/archives/seasar-user/2007-August/011996.html<br />
</a></p>
<p>最適な解は何なんでしょう。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/" />
	</item>
	</channel>
</rss>

