使用NHibernate出现错误"此SqlParameterCollection 的 Count=71 的索引 71 无效"
2011-10-08 10:38
555 查看
使用nhibernate做update操作时出现如下错误:
此 SqlParameterCollection 的 Count=71 的索引 71 无效。
XML文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PERSON, Sgidi.Model" table="PERSON">
<id name="PNUMBER" type="String" unsaved-value="null">
<column name="PNUMBER" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_PERSON_1"/>
<generator class="native" />
</id>
<property name="roomcode" type="String">
<column name="room_code" length="10" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="dept_info" class="dept_info" column="room_code" not-found="ignore"/>
</class>
</hibernate-mapping>
有两种解决方法
1.配置文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PERSON, Sgidi.Model" table="PERSON">
<id name="PNUMBER" type="String" unsaved-value="null">
<column name="PNUMBER" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_PERSON_1"/>
<generator class="native" />
</id>
<property name="roomcode" type="String" insert="false" update="false" >
<column name="room_code" length="10" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="dept_info" class="dept_info" column="room_code" not-found="ignore"/>
</class>
</hibernate-mapping>
但这样的话以后字段roomcode不能进行修改操作
2.配置文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PERSON, Sgidi.Model" table="PERSON">
<id name="PNUMBER" type="String" unsaved-value="null">
<column name="PNUMBER" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_PERSON_1"/>
<generator class="native" />
</id>
<property name="roomcode" type="String" insert="false" update="false" >
<column name="room_code" length="10" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="dept_info" class="dept_info" column="room_code" not-found="ignore"
insert="false" update="false"
/>
</class>
</hibernate-mapping>
参考资料:
reference:
http://codeverity.com/timweaver/nhibernate-invalid-index-for-this-sqlparametercollection/
此 SqlParameterCollection 的 Count=71 的索引 71 无效。
XML文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PERSON, Sgidi.Model" table="PERSON">
<id name="PNUMBER" type="String" unsaved-value="null">
<column name="PNUMBER" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_PERSON_1"/>
<generator class="native" />
</id>
<property name="roomcode" type="String">
<column name="room_code" length="10" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="dept_info" class="dept_info" column="room_code" not-found="ignore"/>
</class>
</hibernate-mapping>
有两种解决方法
1.配置文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PERSON, Sgidi.Model" table="PERSON">
<id name="PNUMBER" type="String" unsaved-value="null">
<column name="PNUMBER" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_PERSON_1"/>
<generator class="native" />
</id>
<property name="roomcode" type="String" insert="false" update="false" >
<column name="room_code" length="10" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="dept_info" class="dept_info" column="room_code" not-found="ignore"/>
</class>
</hibernate-mapping>
但这样的话以后字段roomcode不能进行修改操作
2.配置文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PERSON, Sgidi.Model" table="PERSON">
<id name="PNUMBER" type="String" unsaved-value="null">
<column name="PNUMBER" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_PERSON_1"/>
<generator class="native" />
</id>
<property name="roomcode" type="String" insert="false" update="false" >
<column name="room_code" length="10" sql-type="varchar" not-null="true"/>
</property>
<many-to-one name="dept_info" class="dept_info" column="room_code" not-found="ignore"
insert="false" update="false"
/>
</class>
</hibernate-mapping>
参考资料:
reference:
http://codeverity.com/timweaver/nhibernate-invalid-index-for-this-sqlparametercollection/
相关文章推荐
- 此OracleParameterCollection 的 Count=4 的索引 4 无效 的解决办法 NHibernate
- 此 SqlParameterCollection 的 Count=4 的索引 4 无效。
- datafactory使用中,出现SQLGetDiagField(...SQL_DIAG_ROW_COUNT...) failed 错误
- .NET中使用GridView控件输入数据时出现“ Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"的问题
- 使用NHibernate的时候出现“指定的转换无效”的错误
- 讲一下SqlDataReader的关闭问题,出现"阅读器关闭时尝试调用 FieldCount 无效"(转)
- NHibernate Invalid index N for this SqlParameterCollection with Count=N Exception 简易处理
- 讲一下SqlDataReader的关闭问题,出现"阅读器关闭时尝试调用 FieldCount 无效"
- 错误总结:C/C++运行时提示".exe已停止工作"? 调试时出现Program received signal SIGSEGV,Segmentation fault?引用无效内存一般是什么错误?
- 使用AFN 的POST请求出现错误"Error Domain=NSCocoaErrorDomain Code=3840 "决绝方案
- JAVA错误:使用rs.next()提示"Unhandled exception type SQLException“
- AndroidAnnotations 使用在library项目中出现无法找到R文件下资源索引的错误
- win10安装SQL12时,出现[错误消息] 为 SQL Server 代理服务提供的凭据无效。若要继续操作,请为 SQL Serve
- 解决使用3DSprite出现vertices exceed the max size of vertex buffer, will set count to _vertexNumber-begin错误
- 解决使用SmtpClient类时出现"不允许使用邮箱名称"的错误
- SQL还原数据库时发生错误,"因为数据库正在使用,所以未能获得对数据库的排它访问权。"解决方法。
- 解决解密时出现"要解密的数据的长度无效" 或 "填充无效无法被移除" 的错误
- NHibernate SQL优化小技巧使用dynamic-insert="true" insert="true"
- 求解:此OracleParameterCollection 的 Count=4 的索引 4 无效 NHibernate
- idea中使用scala运行spark出现Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class