English 中文(简体)
运行时错误 - 未知的命名查询 - Nibernate, Oracle, C#
原标题:Runtime Error - Named query not known - Nibernate, Oracle, C#

我看过很多例子和问题/问题/答案。 我不明白为什么我的C#没有看到甲骨文 SP。任何帮助都会感激不尽。

基本目标 -

我有甲骨文 SP (以下显示), 它返回光标作为返回参数 # 1, 并在 # 2 和 # 3 中给出两个字符串参数 。

我从C # 调用SP, 试图将回选结果放入 C # 类抽取 CastalSurvey1SP 列表。 (如下表所示)

我的代码在Nhibertate命令上爆炸了 Get NamedQuery。

Oracle SP、Nhibertate 测绘XML文件、Nhebertate 绘图代码、呼叫代码和运行时错误掉落,全部在下面。

如果你需要更多的信息,告诉我 - 在gmail.com的blalock。

感谢你们的帮助。你们解决此事吧!你们在我眼中称尊为真主吧!祝你们平安!祝你们在有福的日子!

M. 斯科特·巴诺洛克

Runtime Error

Named query not known: PROC_MASSANDABUNDANCE Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.MappingException: Named query not known: PROC_MASSANDABUNDANCE

Source Error:

Line 7257:////query.SetParameter("SPECIESCODE_IN", "6186020202");
Line 7258: Line 7259: IQuery query = Session.GetNamedQuery("PROC_MASSANDABUNDANCE"); Line 7260: query.SetParameter("PROJECTCODE_IN", "P94"); Line 7261: query.SetParameter("SPECIESCODE_IN", "6186020202");

Source File: C:Visual Studio 2008ProjectsSEAMAPSEAMAPSEAMAPServiceDBRepository.cs Line: 7259

Stack Trace:

[MappingException: Named query not known: PROC_MASSANDABUNDANCE] NHibernate.Impl.AbstractSessionImpl.GetNamedQuery(String queryName) +509 SEAMAP.Services.DBRepository.ExtractCoastalSurvey1Collection(String[] _AreaArray, String _LatitudeRangeBegin, String _LatitudeRangeEnd, String _YearRangeBegin, String _YearRangeEnd, String _Season, String _State, String _DepthZone, String[] _SelectedMonthArray, String[] _SelectedYearArray, String[] _SelectedScientificNamesArray, String[] _SelectedCommonNamesArray, String[] _SelectedACCSPGridArray) in C:Visual Studio 2008ProjectsSEAMAPSEAMAPSEAMAPServiceDBRepository.cs:7259 SEAMAP.Controllers.ReportsController.ExtractCoastalSurvey(ExtractCoastalSurveyParameters _model) in C:Visual Studio 2008ProjectsSEAMAPSEAMAPSEAMAPControllersReportsController.cs:277 lambda_method(ExecutionScope , ControllerBase , Object[] ) +140 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +178 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +24 System.Web.Mvc.<>c_DisplayClassd.b_a() +52 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +254 System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters) +192 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34 System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 System.Web.Mvc.Async.<>c__DisplayClass81.b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8699438 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

From ORACLE

PROCEDURE PROC_MASSANDABUNDANCE 
(p_recordset OUT SYS_REFCURSOR,PROJECTCODE_IN IN VARCHAR2, SPECIESCODE_IN IN VARCHAR2) AS 

BEGIN

OPEN p_recordset FOR

SELECT * FROM TABLE;

END PROC_MASSANDABUNDANCE;

Mappings.HMB.XML File

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="SEAMAP" assembly="SEAMAP" >


  <sql-query name="PROC_MASSANDABUNDANCE" Callable="true">
     <query-param name="PROJECTCODE_IN" type="string" />
     <query-param name="SPECIESCODE_IN" type="string" />

    <return class="SEAMAP.Models.ExtractCoastalSurvey1SP" />

    { call PROC_MASSANDABUNDANCE(:PROJECTCODE_IN :SPECIESCODE_IN) } 

  </sql-query>

</hibernate-mapping>

C# Code

Mapping Code

    private static ISessionFactory CreateSessionFactory()
    {
        return Fluently.Configure()
               .Database(OracleClientConfiguration.Oracle10
               .ConnectionString(c => c.FromConnectionStringWithKey(connString))
               .ShowSql())
               .ExposeConfiguration(c => c.SetProperty("current_session_context_class", "web"))
               .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Project>())
               .Mappings(m => m.HbmMappings.AddFromAssemblyOf<Project>())
               .BuildSessionFactory();
    }

Calling Code

                    IQuery query = Session.GetNamedQuery("PROC_MASSANDABUNDANCE");
                    query.SetParameter("PROJECTCODE_IN", "P94");
                    query.SetParameter("SPECIESCODE_IN", "6186020202");

                    return query.List<ExtractCoastalSurvey1SP>();
问题回答

当你把计划名称附在程序之后会怎样呢?就像[计划]一样。[程序]。

对于我在 C# 应用程序中的软件包代码, 我总是把光标放在最后, 但对于流利的硝酸, 这可能不是强制性的 。





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签