#contents

*概要 [#v7ad6951]
S2Dao用のソースコードを自動生成します。

*使用方法 [#pa1ded15]
**Excelでテーブル定義を記述する [#if187297]
テーブル定義の記述には、以下の二通りが使えます。
-Excelのシートの形式 
-[[ERwin:http://www.jsys-products.com/product/al_erwin/]]の出力するCSV形式

**diconファイルを設定する [#i24cd379]
dicon/org/seasar/codegen/impl/LoadFile.diconを、入力ファイルの形式およびRDBにあわせて修正します。
***入力ファイルの形式 [#n67dba50]
-ERwinの出力するCSVファイルを使う場合
 <component class="org.seasar.codegen.impl.ERWinCSVImportCodeData" >
 </component>
-1シート1テーブル形式のExcelシートを使う場合
 <component class="org.seasar.codegen.impl.ExcelImportCodeDataImpl">
 </component>
-1シート複数テーブル形式のExcelシートを使う場合
 <component class="org.seasar.codegen.impl.ExcelImportCodeDataImpl2">
 </component>
***RDBの形式 [#h8ea5eb1]
-DB2の場合
 <component class="org.seasar.codegen.element.util.DB2DataTypeSelectUtil" >
 </component>
-MySQLの場合
 <component class="org.seasar.codegen.element.util.MySQLDataTypeSelectUtilImpl">
 </component>
-MaxDBの場合
 <component class="org.seasar.codegen.element.util.MaxDBDataTypeSelectUtilImpl">
 </component>
-Oracleの場合
 <component class="org.seasar.codegen.element.util.OracleDataTypeSelectUtil">
 </component>
-HSQLDBの場合
 <component class="org.seasar.codegen.element.util.HSQLDBDataTypeSelectUtilImpl">
 </component>
-PostgreSQLの場合
 <component class="org.seasar.codegen.element.util.PostgreSQLDataTypeSelectUtil">
 </component>
-Derbyの場合
 <component class="org.seasar.codegen.element.util.DerbyDataTypeSelectUtil">
 </component>
***テーブル名・カラム名とクラス名・プロパティ名の変換の設定(0.1.0 beta-2からの機能です。) [#j3740809]
-変換を行わない場合
 <component class="org.seasar.codegen.convert.impl.NullConverterImpl">
 </component>

-大文字→小文字の変換および「_」の削除を行う場合
 <component class="org.seasar.codegen.convert.impl.CamelConverterImpl">
 </component>

|種別|変換前|変換後(NullConverterImpl)|変換後(CamelConverterImpl)|
|Dao|EMPLOYEE_TABLE|EMPLOYEE_TABLEDao|EmployeeTableDao|
|Dto|EMPLOYEE_TABLE|EMPLOYEE_TABLEDto|EmployeeTableDto|
|getter|EMPLOYEE_ID|getEMPLOYEE_ID|getEmployeeId|
|setter|EMPLOYEE_ID|setEMPLOYEE_ID|setEmployeeId|

**antのビルドファイルを設定する [#m718aebc]
注意:build.xmlは、配布パッケージ作成のためのファイルです。コード生成のためのファイルの雛形はbuild_sample***.xmlです。

build_sample.xmlを参考にビルドファイルを記述します。
通常は、build_sample.xml内の2つのプロパティを修正すればすむはずです。
 <!-- テープル定義ファイルのパス -->
 <property name="codegen.table" value="test/codegen.csv"/>
 <!-- 出力ファイルのパッケージ名 -->
 <property name="codegen.package" value="org.seasar.codegen.sample"/>

**antタスクを実行する。 [#mfae0799]
ファイル名がbuild_sample.xmlの場合、
 ant -f build_sample.xml
でソースが生成されます。

**注意点 [#w30237c9]
-S2Dao-CodeGenで生成したソースをコンパイル、実行するには[[S2Coffee]]が必要です。jarファイルはhttp://s2coffee.sandbox.seasar.org/archive/s2-coffee-0.1.0.jarからダウンロードしてください。(配布物内のlib/ディレクトリ内にもjarファイルが含まれています。)

*開発情報 [#pb258164]
**TODO [#ee428096]
+S2DaoのサンプルDBに対してソース生成した時のテストケースを書く
+対応DBを増やす
+pagerに対応する。
+%%UnlessUpdateに対応する%%→無理
+DDL出力
+%%入力フォーマットにExcelを追加する%%
+%%S2DaoのサンプルDBを元にサンプルを作る%%
+%%テーブル名+カラム名を大文字+「_」で記述したときにJavaの標準的なクラス名・フィールド名になるようにする。%%
+IDのような大文字だけの定義があった場合、フィールド名をIDとなるようにする。(現状、iDとなる)
+%%Daoのメソッド・シグネチャーにGenericsを使用可能にする%%
+%%実テーブルからリバース%%(→マッピング情報をどこから取得するかが課題)
+S2Dao Tiger対応
+DTOのJavaDocコメントを生成する。

**検討課題 [#q96355dc]
+S2Daoの「更新されたプロパティのみをUPDATE文に含める」機能を、DTOを直接newした場合にも使用可能にする。
+%%FindDtoを<ルートパッケージ>.dtoパッケージに出力可能にする。%%→不要
+Daoの生成にgenaration gapパターンの使用を可能にする。
+Daoのクラス名は定義書等で指定できるようにする。
+シーケンス名を定義書等で指定できるようにする。
+ソース生成後、antタスク内でコンパイルするようにする
+検索条件の or 、group by 対応
+Maven2対応
+S2Daoの1:Nマッピングに対応する
+DTOのequalsメソッドの生成
+Doltengと連携..?

**参考資料 [#je9a4f18]
-[[入力フォーマット>./InputFormat]]
-[[クラス図など>./Model]]

*DB対応作業分担表 [#q770c9e2]
|DB|担当|
|DB2|対応済み|
|MaxDB|対応済み|
|Derby|対応済み|
|Oracle|makotan|
|SQLServer|azusa|
|MySQL|azusa|
|PostgreSQL|makotan|
|HSQLDB|azusa|
|Firebird||
|H2|azusa|

*メーリングリスト [#ee5dd031]
[[Seasar-devメーリングリスト:https://www.seasar.org/mailman/listinfo/seasar-dev]]で開発に関する議論を行なっています。

*SVNレポジトリ [#x32066d2]
https://www.seasar.org/svn/sandbox/s2dao-codegen/

*ダウンロード [#v89a6b50]
http://s2dao-codegen.sandbox.seasar.org/download/

http://s2dao-codegen.sandbox.seasar.org/snapshot/
からレポジトリのsnapshotをダウンロードできます。

*[[DBFlute]]との機能比較 [#vf0491f6]
[[CompareDBFluteWithCodeGen]]に一覧表があります。

*コメント [#wfef3891]
ジェネレータに、組み込んで欲しい機能の要望があれば、気軽にコメントをどうぞ!

#pcomment(Comment/Sandbox/S2Dao-CodeGen,10,reply)

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS