nhibernate在winForm中连接oracle出错:
in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [from S_USER]
我根据网上的例子建了两个类库:
BLL及Model
在Model里有实体类
s_User:(对应Oracle表: s_user)
namespace Model
{
    public class s_USER
    {
        private Int32 _UserNo;
        private string _UserName;
        private string _Password;
        private Int32 _Status;
        private string _Re;
        private Int32 _RoleNo;
        public virtual Int32 UserNo 
        { 
            get{return _UserNo;}
            set { _UserNo = value; }
        }
        public virtual string UserName 
        {
            get { return _UserName; }
            set { _UserName = value; }
        }
        public virtual string Password
        {
            get { return _Password; }
            set { _Password = value; }
        }
        public virtual Int32 Status
        {
            get { return _Status; }
            set { _Status = value; }
        }
        public virtual string Re
        {
            get { return _Re; }
            set { _Re = value; }
        }
        public virtual Int32 RoleNo
        {
            get { return _RoleNo; }
            set { _RoleNo = value; }
        }
    }
}对应建立映射文件:
s_USER.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping   xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
  <class name ="Model.s_USER,Model" table="S_USER">
    <id name="UserNo" column="UserNo" type="Int32">
      <generator class ="native"></generator>
    </id>
    <property name="UserName" column ="UserName" type="string" length="128" not-null="false"></property>
    <property name="Password" column="Password" type="string" length="256" not-null="false" ></property>
    <property name="Status" column ="Status" type="Int32" ></property>
    <property name="Re" column ="Re" type="string" length="256" not-null="false" ></property>
    <property name="RoleNo" column="RoleNo" type="Int32"></property>
  </class>
</hibernate-mapping>在启动项目的hibernate.cfg.xml文件配置为:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
  <session-factory name="NHibernateTest">
    <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
    <!--<property name="connection.provider">
      NHibernate.Connection.DriverConnectionProvider
    </property>-->
    <property name="connection.connection_string">
      Data Source=ORCL;User ID=energy;Password=energy
    </property>
    
    <property name="adonet.batch_size">10</property>
    <property name="default_schema">APP_ADMIN</property>
    <property name="show_sql">true</property>
    <property name="dialect">NHibernate.Dialect.OracleDialect</property>
    <property name="use_outer_join">false</property>
    <property name="command_timeout">10</property>
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
    <mapping assembly="Model"/>
  </session-factory>
</hibernate-configuration>麻烦各位大神帮忙看看哪里出错了,这几个配置文件winformoracle

解决方案 »

  1.   

    还在在BLL类库里调用时出错:
    namespace BLL
    {
        public class UserInfoBLL
        {
            private string path = System.Environment.CurrentDirectory + @"\hibernate.cfg.xml";
            public IList<s_USER> GetUsers()
            {
                Configuration cfg = new Configuration().Configure(path);
                ISession session = cfg.BuildSessionFactory().OpenSession();            //使用HQL
                //IList<s_USER> list = session.CreateQuery("from s_user")
                //    .List<s_USER>();
                IList<s_USER> list = session.CreateQuery("from S_USER").List<s_USER>();            return list;
            }
    }
    }
    在执行红色代码那里报以上错误
      

  2.   

       首先你应当确定实体类映射文件(classname.hbm.xml)的生成方式为嵌入的资源
      IList<s_USER> list = session.CreateQuery("from S_USER").List<s_USER>();   在这里S_USER是跟数据库表存在映射关系的实体类名,不是数据库表名,
    试试
     IList<s_USER> list = session.CreateQuery("from s_USER").List<s_USER>();