は、あなたはiBatisのは、いくつかのオブジェクトにマッピングする方法の方法を完全に制御を取得したいのですが。
これはITypeHandlerCallbackで行うことができます。 「3.5.5カスタム・タイプ・ハンドラ」のセクションのPDF documentationに詳細な説明があります。
私はDataTablesと同様のことをしました。実装は次のようになります。
class DataTableBuilder : ITypeHandlerCallback
{
public object GetResult(IResultGetter getter)
{
IDataReader reader = getter.DataReader;
// (A) define whatever type you want to
// (B) read rows from DataReader and populate your type from (A)
while (reader.Read())
{
// iterate over the columns of the current row
for (int i = 0; i < reader.FieldCount; i++)
{
// populate your type from (A)
}
}
return ...; // return your type from (A)
}
// implement the other members of ITypeHandlerCallback
// the implementation below actually worked for me
public object NullValue { get { return null; } }
public void SetParameter(IParameterSetter setter, object parameter) { }
public object ValueOf(string s) { return s; }
}
最後の注意:iBatisは、データ転送オブジェクト(DTO)の構築に適しています。上記のようなことを試してみると、すでにビジネスオブジェクトアプローチに移行している可能性があります。これは、iBatisで痛いかもしれません。現在(よく...数ヶ月間、時間の不足のために)私は代替としてNHibernateを評価しています。私はNHibernateがiBatisよりもはるかにスムーズにビジネスオブジェクトのアプローチを扱っていると思います。