NHibernate Oracle存储过程问题

发布于 2024-08-19 20:34:03 字数 1596 浏览 7 评论 0原文

------使用VS2008、ASP.Net与C#、Oracle、NHibernate---- 我已经测试了我的存储过程。它可以工作,但不适用于 NHibernate。以下是代码:

过程:

create or replace procedure ThanaDelete (id number) as
begin
 delete from thana_tbl where thana_code = id;
end

映射文件:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataTransfer" namespace="DataTransfer">
  <class name="DataTransfer.Models.Thana, DataTransfer" table="THANA_TBL">
    <id name="THANA_CODE" column="THANA_CODE" type="Int32" unsaved-value="0">
      <generator class="native">
        <param name="sequence">
          SEQ_TEST
        </param>
      </generator>
    </id>
    <property name="THANA_NAME" column="THANA_NAME" type="string" not-null="false"/>
    <property name="DISTRICT_CODE" column="DISTRICT_CODE" type="Int32" not-null="false"/>
    <property name="USER_ID" column="USER_ID" type="string" not-null="false"/>
    <property name="TRANSACTION_DATE" column="TRANSACTION_DATE" type="Date" not-null="false"/>
    <property name="TRANSACTION_TIME" column="TRANSACTION_TIME" type="string" not-null="false"/>

    <sql-delete>exec THANADELETE ? </sql-delete>
  </class>
</hibernate-mapping>

错误:

Message: could not delete: [DataTransfer.Models.Thana#10][SQL: exec THANADELETE ?]
Source: NHibernate
Inner Exception
    System.Data.OracleClient.OracleException
    Message: ORA-00900: invalid SQL statement

------Using VS2008, ASP.Net with C#, Oracle, NHibernate----
I have tested my stored procedure. It's working but not with NHibernate. Here are the codes:

Procedure :

create or replace procedure ThanaDelete (id number) as
begin
 delete from thana_tbl where thana_code = id;
end

Mapping File:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataTransfer" namespace="DataTransfer">
  <class name="DataTransfer.Models.Thana, DataTransfer" table="THANA_TBL">
    <id name="THANA_CODE" column="THANA_CODE" type="Int32" unsaved-value="0">
      <generator class="native">
        <param name="sequence">
          SEQ_TEST
        </param>
      </generator>
    </id>
    <property name="THANA_NAME" column="THANA_NAME" type="string" not-null="false"/>
    <property name="DISTRICT_CODE" column="DISTRICT_CODE" type="Int32" not-null="false"/>
    <property name="USER_ID" column="USER_ID" type="string" not-null="false"/>
    <property name="TRANSACTION_DATE" column="TRANSACTION_DATE" type="Date" not-null="false"/>
    <property name="TRANSACTION_TIME" column="TRANSACTION_TIME" type="string" not-null="false"/>

    <sql-delete>exec THANADELETE ? </sql-delete>
  </class>
</hibernate-mapping>

error:

Message: could not delete: [DataTransfer.Models.Thana#10][SQL: exec THANADELETE ?]
Source: NHibernate
Inner Exception
    System.Data.OracleClient.OracleException
    Message: ORA-00900: invalid SQL statement

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贱人配狗天长地久 2024-08-26 20:34:03

我刚刚有一个带有 sql 查询的 ORA-00900。重写你的 SQL 可能

begin exec THANADELETE ?; end;

会解决问题

I just had an ORA-00900 with an sql-query. Rewriting your SQL as

begin exec THANADELETE ?; end;

might solve the problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文