[nhibernate]NHibernate储存过程ORACLE时提示"ORA-00911: invalid character"

2008-08-03 VC 阅读:

 我的hibernate.cfg.xml

代码hibernate.cfg.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
3 <session-factory>
4 <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
5 <property name="connection.driver_class"> NHibernate.Driver.OracleDataClientDriver</property>
6 <property name="connection.connection_string">
7 data source=GXLX193;user id=lxmis;password=lxmis
8 </property>
9 <property name="adonet.batch_size">10</property>
10 <property name="connection.release_mode">auto</property>
11 <property name="show_sql">true</property>
12 <property name="use_outer_join">true</property>
13 <property name="dialect"> NHibernate.Dialect.Oracle10gDialect</property>
14 <property name="command_timeout">10</property>
15 <property name="query.substitutions">true 1, false 0, yes "Y", no "N"</property>
16 <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
17 <property name="hbm2ddl.keywords">none</property>
18 <mapping assembly="Model" />
19 </session-factory>
20 </hibernate-configuration>


我的hbm.xml
.hbm.xml代码
1<?xml version="1.0" encoding="utf-8"?>
2<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
3 <sql-query name="Dualsa">
4 {Call pro_GetAllA(:k)}
5 </sql-query>
6 <sql-query name="aaa">
7 select a.FID as id,
8 a.PARAM_VALUE as va
9 from T_PARAMS a
10 </sql-query>
11</hibernate-mapping>
12

我的错误代码
 
1 class Program
2 {
3 static void Main(string[] args)
4 {
5 ISession _ISeesion = new SessionManager().GetSession();
6 IQuery q = _ISeesion.GetNamedQuery("Dualsa");
7 IList list = q.SetInt32("k", 0).List();
8 }
9 }
错误信息是:Message="could not execute query\r\n[ {call up_test (:p0,:p1) } ]\r\n Name:pInt - Value:100 Name:pString - Value:hello\r\n[SQL: {call up_test (:p0,:p1) }]"
ORA-00911: invalid character
为了说明我能执行其他的,我试了调用aaa是正常的,可以执行有结果


我的正确代码

class Program
{
static void Main(string[] args)
{
ISession _ISeesion = new SessionManager().GetSession();
IQuery q = _ISeesion.GetNamedQuery("aaa");
IList list = q.List();//正确有结果的

}
}


我的储存过程

1 create or replace procedure pro_GetAllA( my_cursor out sys_refcursor,k int ) as
2 begin
3 open my_cursor for select a.FID as id,
4 a.PARAM_VALUE as va
5 from T_PARAMS a;
6 end pro_GetAllA;

我改用另一种方法了,
<property name="connection.driver_class"> NHibernate.Driver.OracleDataClientDriver</property>
改回原来的OracleClientDriver
去掉Oracle.DataAccess.dll的引用
直接使用

ISession _ISeesion = new SessionManager().GetSession();
IDbCommand _cmd = _ISeesion.Connection.CreateCommand();
_cmd.CommandText = "pro_GetAllA";
_cmd.CommandType = CommandType.StoredProcedure;
System.Data.OracleClient.OracleCommandBuilder.DeriveParameters((System.Data.OracleClient.OracleCommand)_cmd);

IDataReader _IDReader = _cmd.ExecuteReader();
object[] _o = new object[_IDReader.FieldCount];
while (_IDReader.Read())
{
for (int i = 0; i < _IDReader.FieldCount; i++)
_o[i] = _IDReader[i];
}

[nhibernate]NHibernate储存过程ORACLE时提示"ORA-00911: invalid character"

http://m.quanqiunao.cn/bianchengkaifa/5144/

推荐访问:nhibernate缓存机制 nhibernate介绍

VC推荐文章

推荐内容

上一篇:mvc下的数据类型|MVC下的数据绑定服务器控件 下一篇:nod32 用户名和密码_NOD32 升级ID- EAV版和ESS版2.7/3.0