- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个遗留应用程序 (vfp 8),我需要从中提取数据(无插入)。我使用 Accnum 字段作为主键,它在表中定义为字符 11。
出厂配置:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<reflection-optimizer use="false" />
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.GenericDialect</property>
<property name="connection.driver_class">NHibernate.Driver.OleDbDriver</property>
<property name="connection.connection_string">Provider=VFPOLEDB.1;Data Source=C:\Analysis\Quantium\development\RD warehouse\_RDAUWH\Data;Collating Sequence=MACHINE</property>
<property name="show_sql">false</property>
</session-factory>
</hibernate-configuration>
这是我的映射文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="RDLabels"
namespace="RDLabels.Domain">
<class name="CustMast">
<id name="Accnum" column="Accnum" type="string">
<generator class="assigned"/>
</id>
<property name="Fullname" />
<property name="Add" />
<property name="State" />
</class>
</hibernate-mapping>
类(class):
public class CustMast
{
private string _accnum;
public virtual string Accnum
{
get { return _accnum; }
set { _accnum = value; }
}
private string _fullname;
public virtual string Fullname
{
get { return _fullname; }
set { _fullname = value; }
}
private string _add;
public virtual string Add
{
get { return _add; }
set { _add = value; }
}
private string _state;
public virtual string State
{
get { return _state; }
set { _state = value; }
}
}
获取记录的代码如下:
public CustMast GetByAccnum(String accnum)
{
using (ISession session = NHibernateHelper.OpenSession())
{
CustMast custMast = session
.CreateCriteria(typeof(CustMast))
.Add(Restrictions.Eq("Accnum", accnum))
.UniqueResult<CustMast>();
return custMast;
}
}
完整的错误是:
NHibernate.Exceptions.GenericADOException : could not execute query
[ SELECT this_.Accnum as Accnum0_0_, this_.Fullname as Fullname0_0_, this_.Add as Add0_0_, this_.State as State0_0_ FROM CustMast this_ WHERE this_.Accnum = ? ]
Name:cp0 - Value:00059337444
[SQL: SELECT this_.Accnum as Accnum0_0_, this_.Fullname as Fullname0_0_, this_.Add as Add0_0_, this_.State as State0_0_ FROM CustMast this_ WHERE this_.Accnum = ?]
----> System.IndexOutOfRangeException : Invalid index 0 for this OleDbParameterCollection with Count=0. - d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:1590
运行 NHibernate Profiler 它显示:
WARN:
reflection-optimizer property is ignored out of application configuration file.
WARN:
System.IndexOutOfRangeException: Invalid index 0 for this OleDbParameterCollection with Count=0.
at System.Data.OleDb.OleDbParameterCollection.RangeCheck(Int32 index)
at System.Data.OleDb.OleDbParameterCollection.GetParameter(Int32 index)
at System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32 index)
at NHibernate.Driver.DriverBase.ExpandQueryParameters(IDbCommand cmd, SqlString sqlString) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Driver\DriverBase.cs:line 235
at NHibernate.AdoNet.AbstractBatcher.ExpandQueryParameters(IDbCommand cmd, SqlString sqlString) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\AdoNet\AbstractBatcher.cs:line 232
at NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters queryParameters, Boolean scroll, ISessionImplementor session) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:line 1152
ERROR:
Invalid index 0 for this OleDbParameterCollection with Count=0.
最佳答案
每当我向它们传递参数时,我都在努力处理我的 linq 查询并抛出相同的错误。如果我不传递任何参数并执行 session.Query(),它们会正常工作。
我为此苦苦挣扎了好几天,但我找到了这张 Nhibernate jira 票证 here .它解释了 SQLParameters 和 Iseries Db2 提供程序的一个明显问题。
我知道您使用的是不同的供应商,但您可能会从下载最新的 Nhibernate 核心源代码、构建它并在您的项目中引用最新版本中获益。它解决了我的问题。
关于c# - NHibernate.Exceptions.GenericADOException : could not execute query 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8774702/
我正在尝试将 NHibernate 与 ByCode 映射结合使用,但收效甚微。知道我做错了什么吗? 我的 table : CREATE TABLE [dbo].[activities]( [
我有这个 return session.Query().Where(x => x.Student.StudentId == studentId).ToList(); 我明白了 NHibernate
我有两个表,tableA 和 tableB。 tableA 有列:tabAId、col2、col3 (tabAId primaryKey 和 Identity 列。) tableB 有列:tabAId
我有一个 NHibernate 查询(它正在填充一个 EXTJS 网格) 它向数据库发出 2 个查询,一个用于获取记录计数(用于分页),另一个用于获取前 N 行以填充网格。 从代码中,我一直在 Sel
我有一个遗留应用程序 (vfp 8),我需要从中提取数据(无插入)。我使用 Accnum 字段作为主键,它在表中定义为字符 11。 出厂配置: NHibernate.Connection.Dr
通过 mysql 更新时出现异常,同样的代码适用于 microsoft sql。 mysql服务器版本5.6.28 string connectionString = "Server=xxxx.is;
我有以下看似随机发生的异常: NHibernate.Exceptions.GenericADOException: could not execute query [ select b
我一直在使用 ISession.Refresh() 遇到奇怪的行为(至少对我而言) . 我有一个带有延迟加载的子项集合的实体,以及一个命中该集合的只读属性,所有这些都包含在二级缓存中。 我用 ISes
我捕获了 InnerException.Message = "Unique key violation ..."的 GenericADOException,用于告诉用户输入的登录名已被使用。 之后我试
我是一名优秀的程序员,十分优秀!