An Easier Java ORM(6) 動く!

http://www.javalobby.org/articles/activeobjects/の日本語訳です。<< An Easier Java ORM(5) Active Recordパターンを実装する - 目次に戻る - An Easier Java ORM(7) おわりに >>

動く! - It Lives!

すでにこのブレインストーミングとプロトタイピングは成果は作成されています。サンプルコードで説明したのは架空のプロトタイプコードではなく、ActiveObjects ORMで実際に動作するコードです。

The product of all of this brainstorming and prototyping has already been created. What I've been describing in the code samples provided was not just some theoretical, prototype code but actually working code which can be run against the ActiveObjects ORM.

ActiveObjectsはできる限り単純になるようにゼロから設計されています。(APIユーザにとって)必要なのは、インタフェースのマッピングを作成し、クラスパスにJDBCドライバを正しく配置するだけです。データベースアクセスの詳細は全部ActiveObjectsが行います。接続プーリングも、クラスパスにプーリングライブラリを置くだけで行えます(現在、DBCPとC3P0、Proxoolをサポートしています)。

ActiveObjects is designed from the ground up to be as absolutely simple as possible. Just about all that is required of you (the API user) is to create the interface mappings and place the appropriate JDBC driver in the classpath. All of the details of the database access layer are completely handled by ActiveObjects. You can even enable connection pooling simply by placing a pooling library in the classpath (DBCP, C3P0 and Proxool are currently supported). ActiveObjects allows you to work with the database as naturally as you would work with a standard object-oriented class hierarchy, avoiding all of the complications associated with multi-database deployment and SQL.

ActiveObjectsではエンティティインタフェースの定義に基づいて、データベーススキーマを生成することもできます。別の(そして、より頻繁に起こる)状況として、すでに存在するスキーマにフィールドの追加(または削除)を行う場合には、ActiveObjectは既存のスキーマから新しいバージョンへ移行するための適切なDDLを生成します。これにより、オブジェクト指向の開発者は、オブジェクトについてだけ考えればよく、裏にあるデータベースや保存の仕方について一切考慮しなくてよいのです。

ActiveObjects can even generate the database schema for you, just based on your entity interface definitions. Alternatively (and a more common scenario), if the schema already exists in some form, but you've added (or removed) a field, ActiveObjects will generate the appropriate DDL to migrate the existing schema to the new version. This means that, as an object-oriented developer, you can think about the objects themselves, and never give consideration to the underlying database or how they are stored.

現在、ActiveObjectsは以下のデータベースを十分にサポートしています:

Currently, ActiveObjects fully supports the following databases:

クラスパスにドライバのJARを置き、EntityManagerのコンストラクタに渡すJDBC URIを変更するだけで、これらの全てのデータベース上でコードが動きます。XML、プロパティファイルなど設定を扱うための粗悪なものはありません。

Running your code against any one of these databases is as simple as placing the driver JAR in your classpath and changing the JDBC URI passed to the EntityManager constructor. There's no XML, no properties files to deal with, no configuration cruft whatsoever.

ActiveObejctsは(必要であれば)テーブル名の複数化もサポートします。別のTableNameConverterを指定するだけです。

ActiveObjects even supports table name pluralization (if you really want it). All you have to do is specify a different TableNameConverter:

EntityManager manager = new EntityManager("jdbc:mysql://localhost/test", "user", "password");  
manager.setTableNameConverter(new PluralizedNameConverter());  
// ...  

<< An Easier Java ORM(5) Active Recordパターンを実装する - 目次に戻る - An Easier Java ORM(7) おわりに >>