2010-04-16 65 views
1

,我發現每當我打電話使用的Isession 類oracale stordeprocedure一個錯誤,這是我的mappping文件給定的關鍵是不存在的字典

<hibernate-mapping 
xmlns="urn:nhibernate-mapping-2.2" default-access="field" 
assembly="DataContext" namespace="DataContext" > 


<sql-query name="GetEmployeedetails" callable="true"> 
    <return alias="emp" class="empdetails" > 
     <return-property name="U_ID" column="U_ID"/> 
      <return-property name="IUSR_FIRST_NAME" column="IUSR_FIRST_NAME"/> 
       <return-property name="IUSR_LAST_NAME" column="IUSR_LAST_NAME"/> 
     <return-property name="IUSR_EMP_EMAIL_ID" column="IUSR_EMP_EMAIL_ID"/> 
      <return-property name="IUSR_MOBILE_NO" column="IUSR_MOBILE_NO"/> 
     <return-property name="IUSR_REMARKS" column="IUSR_REMARKS"/> 
      <return-property name="IUSR_LOGIN_NAME" column="IUSR_LOGIN_NAME"/> 


    </return> 
    {?=call GETEMPLOYEEDETAILS(:pr_page,:pr_userid) } 

    </sql-query> 

</hibernate-mapping> 

這是我的類文件

amespace DataContext 
{ 
    public class empdetails 
    { 
     public int _ID; 
     private string _IUSR_FIRST_NAME; 
     private string _IUSR_LAST_NAME; 
     private string _IUSR_EMP_EMAIL_ID; 
     private string _IUSR_MOBILE_NO; 
     private string _IUSR_REMARKS; 
     private string _IUSR_LOGIN_NAME; 
     // private DateTime _IUSR_CREATED_ON; 


     //public empdetails(int U_ID, string IUSR_FIRST_NAME, string IUSR_LAST_NAME, string IUSR_LOGIN_NAME, string IUSR_EMP_EMAIL_ID, string IUSR_MOBILE_NO, string IUSR_REMARKS)//, DateTime iusrcreated) 
     //{ 
     // this._ID = U_ID; 
     // // _IUSR_FIRST_NAME = iusrfname; 
     // this._IUSR_FIRST_NAME = IUSR_FIRST_NAME; 
     // this._IUSR_LAST_NAME = IUSR_LAST_NAME; 
     // this._IUSR_LOGIN_NAME = IUSR_LOGIN_NAME; 
     // this._IUSR_EMP_EMAIL_ID = IUSR_EMP_EMAIL_ID; 
     // this._IUSR_MOBILE_NO = IUSR_MOBILE_NO; 
     // this._IUSR_REMARKS = IUSR_REMARKS; 
     // // _IUSR_CREATED_ON = iusrcreated; 

     //} 

     public empdetails() 
     { 
     } 
     public virtual int U_ID 
     { 
      get { return _ID; } 
      set { _ID = value; } 
     } 

     public virtual string IUSR_FIRST_NAME 
     { 
      get { return _IUSR_FIRST_NAME; } 
      set 
      { 
       _IUSR_FIRST_NAME = value; 
      } 

     } 
     public virtual string IUSR_LAST_NAME 
     { 
      get { return _IUSR_LAST_NAME; } 
      set 
      { 
       _IUSR_LAST_NAME = value; 
      } 

     } 
     public virtual string IUSR_LOGIN_NAME 
     { 
      get { return _IUSR_LOGIN_NAME; } 
      set 
      { 
       _IUSR_LOGIN_NAME = value; 
      } 

     } 
     public virtual string IUSR_EMP_EMAIL_ID 
     { 
      get { return _IUSR_EMP_EMAIL_ID; } 
      set 
      { 
       _IUSR_EMP_EMAIL_ID = value; 
      } 


     } 
     public virtual string IUSR_MOBILE_NO 
     { 
      get { return _IUSR_MOBILE_NO; } 
      set 
      { 
       _IUSR_MOBILE_NO = value; 
      } 

     } 
     public virtual string IUSR_REMARKS 
     { 
      get { return _IUSR_REMARKS; } 
      set 
      { 
       _IUSR_REMARKS = value; 
      } 

     } 

    } 

我的控制器類

public ActionResult Index() 
     { 
      // OracletestModule ot=new OracletestModule(); 
      //ot.GETEMPDETAILS(17); 
      //return View(ot); 

      ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSessionFactory(); 
      using (ISession session = factory.OpenSession()) 
      { 


       var namedQuery = session.GetNamedQuery("GetEmployeedetails"); 
       namedQuery.SetParameter("pr_userid", 17); 
       // IList list = namedQuery.List(); 
       IList list = (IList)namedQuery.List(); 
       return View(); 
      } 


     } 

oracle存儲過程

create or replace 
PROCEDURE GETEMPLOYEEDETAILS 
(
pr_page out SYS_REFCURSOR, 
pr_userid test.U_ID%TYPE 


) 
AS 
BEGIN 
open pr_page for 
select 
     U_ID, 
     IUSR_FIRST_NAME, 
     IUSR_LAST_NAME, 
     IUSR_EMP_EMAIL_ID, 
     IUSR_MOBILE_NO, 
     IUSR_REMARKS, 
     IUSR_LOGIN_NAME 

from test where U_ID= pr_userid; 
END GETEMPLOYEEDETAILS; 

plz幫助我,我所做的錯誤

在此先感謝

+2

更多詳細的錯誤創建請 – Ando 2010-04-16 09:30:24

回答

0

此錯誤通常,當您要查詢未映射類中發生。你有empdetails的映射文件嗎?

+0

感謝烏拉圭回合重播 我Mapping.ByCodeClassMapping類我複製類map.PropertyRef("Id");的解決了這個問題文件empdetails也PLZ檢查它PLZ給我一個適當的解決方案 – sandeep 2010-04-16 13:20:08

+0

我看到empdetails類,但我沒有看到一個NHibernate映射文件empdetails。如果empdetails沒有映射,那麼你會得到這個錯誤。如果你想使用帶有未映射類的查詢,請看這個問題:http://stackoverflow.com/questions/660820/using-unmapped-class-with-nhibernate-named-query。 – 2010-04-16 13:32:21

+0

在哪裏創建和使用nhibernate映射文件PLZ給我一個例子 謝謝各有不同嗎? – sandeep 2010-04-21 07:29:21

0

我通過刪除所有已添加的我ManyToOne地圖由NHibernate Mapping Generator

相關問題