1

あるクエリの出力が別のクエリの入力として使用されるように変換される、連鎖/パイプライン化されたクエリをサポートするフレームワークをJavaで作成しようとしています。PyCascadingのようなものこれらのクエリは実行時に行われます。私はいくつかのフレームワークを調べ、Apache CamelSpring Integrationがチェーンとルーティング(エンタープライズ統合パターン)の概念を提供していることに気づきました。私はApacheCamelがSpringIntegration(IMHO)よりも優れていることを発見しました。


フレームワークにApacheCamelを使用する必要がありますか、それともこれを実現するためのより良い方法がありますか?

私のクエリ構文は

Query query1 = "select customer.id from customer where customer.name = 'ABC'";
Query query2 = "select account.id from account where account.custid in {$1}";
// $1 will be the input of second query
from(query1).inputto(query2).printOutput();
4

1 に答える 1

1

これは、camel-jdbcといくつかの基本的なCamel機能(simpleなど)を使用して、結果の解析をインライン化できるようにすることで可能になります...

[CAMEL-JDBC]の結果は、ArrayList [HashMap [String、Object]]としてOUT本体に返されます。Listオブジェクトには行のリストが含まれ、Mapオブジェクトには列名としてStringキーを持つ各行が含まれます。

この結果を使用して、後続のクエリを動的に作成できます...

from("direct:start")
  .setBody(constant("select customer.id as ID from customer where customer.name = 'ABC'"))
  .to("jdbc:myDataSource")

  //now, use simple/ognl to extract the first result and the 'ID' from the Map in the body
  .setBody(simple("select account.id from account where account.custid in ${body[0][ID]}"))
  .to("jdbc:myDataSource")

  .log("ACCOUNT IDS = ${body}");
于 2012-03-02T04:04:58.180 に答える