2012-03-28 15 views
0

NHibernateの新機能です。述語のDateTime比較を使用しようとしているときに変換エラーの原因を突き止めるのに役立つと思っています。NHibernate QueryOverの変換エラー(DB2の日付型)

return _session.QueryOver<ShipmentSegment>() 
       .Where(ss => ss.SegmentOrigin == selOrig) 
       // Whenever I add the predicate for the SegmentDate below 
       // I receive a conversion error 
       .And(ss => ss.SegmentDate == selDate) 
       .List<ShipmentSegment>(); 

例外

NHibernate.Exceptions.GenericADOException was unhandled by user code 
    Message=could not execute query 
[ SELECT this_.ajpro# as ajpro1_28_0_, this_.ajleg# as ajleg2_28_0_, this_.ajpu# as ajpu3_28_0_, this_.ajlorig as ajlorig28_0_, this_.ajldest as ajldest28_0_, this_.segdate as segdate28_0_, this_.ajldptwin as ajldptwin28_0_, this_.ajlfrtype as ajlfrtype28_0_, this_.ajlfrdest as ajlfrdest28_0_, this_.ajtpmfst# as ajtpmfst10_28_0_, this_.ajspplan as ajspplan28_0_, this_.ajhload as ajhload28_0_ FROM go52cst.tstshprte this_ WHERE this_.ajlorig = @p0 and this_.segdate = @p1 ] 
    Name:cp0 - Value:WIC Name:cp1 - Value:3/28/2012 12:00:00 AM 

内部例外

Message=A conversion error occurred. 
     Source=IBM.Data.DB2.iSeries 
     ErrorCode=-2147467259 
     MessageCode=111 
     MessageDetails=Parameter: 2. 
     SqlState="" 
     StackTrace: 


- at IBM.Data.DB2.iSeries.iDB2Exception.throwDcException(MpDcErrorInfo 
mpEI, MPConnection conn) 
- at IBM.Data.DB2.iSeries.iDB2Command.openCursor() 
- at IBM.Data.DB2.iSeries.iDB2Command.ExecuteDbDataReader(CommandBehavior 
behavior) 
- at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() 
- at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) 
- at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, 
    ISessionImplementor session) 
- at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) 
- at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor 
    session, QueryParameters queryParameters, Boolean returnProxies) 
- at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) 

私は正しい方向に私を指すことができます何かを感謝しています。

答えて

1

この特定のiSeries例外に関する私の経験は、ストア・プロシージャー・タイプのADOコマンドのADO.NETコマンド・パラメーター・リストのパラメーター(iDB2TypeParameterの)を作成したときから発生しています。 iDB2DbType.Date、iDB2DbType.Time、またはiDB2DbType.TimeStampのどの種類のiDB2DbTypeを使用するかを明示的に指定する必要がありました。 iSeries ADOプロバイダーは、.NET System.DateTimeタイプからパラメーターを作成するときに、これらの3つのタイプのどちらを使用するかを知ることはできません。

new iDB2Parameter(parameterName, iDB2DbType.Date){ Value = myValue }; 
new iDB2Parameter(parameterName, iDB2DbType.Time){ Value = myValue }; 
new iDB2Parameter(parameterName, iDB2DbType.TimeStamp){ Value = myValue }; 

この例のようにパラメータを手動で作成するのではなく、代わりにNHibernateを使用していることがわかりました。ですから、私は、HibernateのDB2/iSeries用のLINQプロバイダがこれを認識していることを確認します。それはNHibernateに対して何もない、私はそれがDB2/iSeriesの良い、固体のORMを見つけることはほぼ不可能であることが分かった。

関連する問題