***コンテンツ一覧
#ls2

***Torqueって?
TorqueとはデータベースにアクセスするためのAPIです。SQLレスで、さらにOracleやSybaseなど、どの製品を使っているかを意識しないで使用できるI/Fを備えています。~
かっこよくいうと、O/Rマッピング・フレームワーク、というものでしょうか。

***最新版のダウンロード
http://db.apache.org/builds/torque/release/3.1/
より
 torque-3.1.tar.gz
 torque-gen-3.1.tar.gz
が取得可能です。

***使い方メモ
まず、アーカイブが3.1から2つに分かれました。
 torque-3.1.tar.gz
 torque-gen-3.1.tar.gz
なのですが、コードジェネレータとランタイムの二つに分かれたようです。

***ジェネレータのインストール
インストールといった仰々しいものはありませんが、基本的に
-JDBCドライバを./lib/ に配置
-build.properties に使用するデータベースの情報を書く

だけです。

今回は、すでにPostgreSQLでMovableTypeを運用していたので、
+jdbcタスクでスキーマをゲット
+そのスキーマでJavaクラスを作成

という手順になりました。

具体的に変更したのは、build.propertiesの
 torque.project = movabletype
 torque.database.createUrl = jdbc:postgresql://127.0.0.1:5432/mt
 torque.database.buildUrl = jdbc:postgresql://127.0.0.1:5432/mt
 torque.database.url = jdbc:postgresql://127.0.0.1:5432/mt <- mtはデータベース名
 torque.database.driver = org.postgresql.Driver
 torque.database.user = mt
 torque.database.password =
 torque.database.host = 127.0.0.1
 torque.targetPackage = kino.torque.movabletype

ですね。んで
 > ant -f build-torque.xml jdbc
てやると、./schema ディレクトリに schema.xml ができました((たぶん生成されるのはこのファイルのみでしょう))。~
それを[torque.projectの値]-schema.xml にmvして
 > ant -f build-torque.xml
としたら、Javaのソースファイルができました。場所は
 ./src/java <-もともとsrcはないみたい。
です((srcディレクトリと上のschema.xml,velocity.logを消せば、元通りかな))。

***Eclipseで使用する
その際には
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
     <classpathentry kind="src" path="source"/>
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
     <classpathentry kind="lib" path="lib/commons-lang-1.0.1.jar"/>
     <classpathentry kind="lib" path="lib/torque-3.1.jar"/>
     <classpathentry kind="lib" path="lib/stratum-1.0-b3.jar"/>
     <classpathentry kind="lib" path="lib/village-2.0-dev-20030825.jar"/>
     <classpathentry kind="lib" path="lib/commons-logging-1.0.3.jar"/>
     <classpathentry kind="output" path="classes"/>
 </classpath>
のクラスパスが必要でした。


***関連リンク

----
SIZE(10){[[カテゴリ]]}~
SIZE(10){現在のアクセス:&counter;}


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