
Oracle PL/SQLパッケージプロシージャの呼び出しクラスを生成するJavaソースコードジェネレーター。さまざまなパラメータタイプと自動型変換をサポートします。
OBridgeは、Oracle PL/SQLパッケージプロシージャを呼び出すためのシンプルなJavaソースコードジェネレータを提供します。
対応している入力パラメータ、出力パラメータ、戻り値は次のとおりです:
次のタイプは実装できません。JDBCドライバがサポートしていないためです:
生成されたコードはJava 1.6でコンパイルされます。
最新バージョンはreleasesからダウンロードしてください。
ダウンロード後、XML設定ファイルを作成します:
<configuration>
<jdbcUrl>jdbc:oracle:thin:scott/tiger@localhost:1521:xe</jdbcUrl> <!-- jdbc connection string for obridge -->
<sourceRoot>.</sourceRoot> <!-- where to generate sources - related to this configuration file -->
<rootPackageName>hu.obridge.test</rootPackageName> <!-- root Java package, generator builds the directory structure -->
<packages>
<entityObjects>objects</entityObjects> <!-- object types are going to this package -->
<converterObjects>converters</converterObjects> <!-- converter util classes are going to this package -->
<procedureContextObjects>context</procedureContextObjects> <!-- procedure parameter entities are going to this package -->
<packageObjects>packages</packageObjects> <!-- procedure calling utility classes are going to this package -->
</packages>
</configuration>
ジェネレータを実行:
java -jar obridge.jar -c <obridge-config.xml>
OBridgeは指定されたデータベースに接続し、必要なクラスを生成します。
例えば、次のPL/SQLコードがあるとします:
Create Or Replace Package simple_procedures is
Function simple_func(a In Varchar2,
b In Out Varchar2,
c Out Varchar2) Return Number;
End simple_procedures;
生成されたソース:
public class SimpleProcedures {
public static SimpleProceduresSimpleFunc simpleFunc(String a, String b, Connection connection) throws SQLException { ... }
}
SimpleProcedures.simpleFuncメソッドを次のように呼び出せます:
SimpleProceduresSimpleFunc ret = SimpleProcedures.simpleFunc("hello", "world", conn); // conn is the database connection
戻り値のオブジェクトは入力パラメータと出力パラメータを保持し、Java型に変換されます。
public class SimpleProceduresSimpleFunc {
private BigDecimal functionReturn;
private String a;
private String b;
private String c;
// getters, setters
}