首页 新闻 搜索 专区 学院

Access many to one

0
悬赏园豆:20 [待解决问题]
DoorLog.cs
using System;
using System.Collections;

namespace FC100.Model
{
    #region DoorLog

    /// <summary>
    /// DoorLog object for NHibernate mapped table 'DoorLog'.
    /// </summary>
    public class DoorLog
    {
        #region Member Variables
        
        protected string _id;
        protected DateTime _dldatetime;
        protected int _dltype;
       protected Tennement _tenement;
        #endregion

        #region Constructors

        public DoorLog() { }

        public DoorLog( DateTime dldatetime, int dltype )
        {
            this._dldatetime = dldatetime;
            this._dltype = dltype;
        }

        #endregion

        #region Public Properties

        public string Id
        {
            get {return _id;}
            set
            {
                if ( value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for Id", value, value.ToString());
                _id = value;
            }
        }        

        public DateTime Dldatetime
        {
            get { return _dldatetime; }
            set { _dldatetime = value; }
        }

        public int Dltype
        {
            get { return _dltype; }
            set { _dltype = value; }
        }

        public Tennement Dltenement
        {
            get
            {
                return _tenement;
            }
            set
            {
                _tenement = value;
            }
        }

        #endregion
    }
    #endregion
}
Tennement.cs
using System;
using System.Collections;

namespace FC100.Model
{
    #region Tennement

    /// <summary>
    /// Tennement object for NHibernate mapped table 'Tennement'.
    /// </summary>
    public class Tennement
    {
        #region Member Variables
        
        protected string _id;
        protected string _ttroomid;
        protected string _ttidno;
        protected string _ttname;
        protected byte[] _ttfingerprint;
       protected System.Collections.IList _doorloglist;
        #endregion

        #region Constructors

        public Tennement() { }

        public Tennement( string ttroomid, string ttidno, string ttname, byte[] ttfingerprint )
        {
            this._ttroomid = ttroomid;
            this._ttidno = ttidno;
            this._ttname = ttname;
            this._ttfingerprint = ttfingerprint;
        }

        #endregion

        #region Public Properties

        public string Id
        {
            get {return _id;}
            set
            {
                if ( value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for Id", value, value.ToString());
                _id = value;
            }
        }

        public string Ttroomid
        {
            get { return _ttroomid; }
            set
            {
                if ( value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for Ttroomid", value, value.ToString());
                _ttroomid = value;
            }
        }

        public string Ttidno
        {
            get { return _ttidno; }
            set
            {
                if ( value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for Ttidno", value, value.ToString());
                _ttidno = value;
            }
        }

        public string Ttname
        {
            get { return _ttname; }
            set
            {
                if ( value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for Ttname", value, value.ToString());
                _ttname = value;
            }
        }

        public byte[] Ttfingerprint
        {
            get { return _ttfingerprint; }
            set { _ttfingerprint = value; }
        }

        public System.Collections.IList Doorloglist
        {
            get
            {
                return _doorloglist;
            }
            set
            {
                _doorloglist = value;
            }
        }

        #endregion
    }
    #endregion
}
DoorLog.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
    <class name="FC100.Model.DoorLog, FC100.Model" table="DoorLog" lazy="false">
        <id name="Id" type="String" unsaved-value="null">
            <column name="dl_id" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_DoorLog"/>
            <!--<generator class="native" />-->
        </id>
        <property name="Dldatetime" type="DateTime">
            <column name="dl_datetime" length="8" sql-type="datetime" not-null="true"/>
        </property>
        <property name="Dltype" type="Int32">
            <column name="dl_type" length="4" sql-type="int" not-null="true"/>
        </property>   
    <many-to-one name="Dltenement" column="tt_id" not-null="true"></many-to-one>
    </class>
</hibernate-mapping>

 

Tennement.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
    <class name="FC100.Model.Tennement, FC100.Model" table="Tennement" lazy="false">
        <id name="Id" type="String" unsaved-value="null">
            <column name="tt_id" length="50" sql-type="varchar" not-null="true" unique="true" index="PK_Tennement"/>
            <!--<generator class="native" />-->
        </id>
        <property name="Ttroomid" type="String">
            <column name="tt_roomid" length="50" sql-type="varchar" not-null="true"/>
        </property>
        <property name="Ttidno" type="String">
            <column name="tt_idno" length="50" sql-type="varchar" not-null="true"/>
        </property>
        <property name="Ttname" type="String">
            <column name="tt_name" length="50" sql-type="varchar" not-null="true"/>
        </property>
  <property name="Ttfingerprint" type="Byte[]">
            <column name="tt_fingerprint" length="16" sql-type="image" not-null="true"/>
        </property>
    <bag name="Doorloglist" table="Tennement" inverse="true" lazy="true" cascade="all">
      <key column="tt_id"/>
      <one-to-many class="FC100.Model.DoorLog, FC100.Model"></one-to-many>
    </bag>
    </class>
</hibernate-mapping>

 

Nhibernate.cfg.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.release_mode">on_close</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
    <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
    <property name="connection.connection_string">provider=Microsoft.Jet.OLEDB.4.0;Data Source=App_Data\Probuck_LockSystem_DataBase.mdb;</property>
    <property name="show_sql">true</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property>
    <property name="use_outer_join">true</property>
    <!-- mapping files 领域对象映射文件所在程序集 -->
    <mapping assembly="FC100.Model"/>
  </session-factory>
</hibernate-configuration>

错误:在 Antlr.Runtime.NoViableAltException 中第一次偶然出现的“NHibernate.dll”类型的异常
在 Antlr.Runtime.NoViableAltException 中第一次偶然出现的“NHibernate.dll”类型的异常
在 Antlr.Runtime.NoViableAltException 中第一次偶然出现的“NHibernate.dll”类型的异常
在 NHibernate.Hql.Ast.ANTLR.QuerySyntaxException 中第一次偶然出现的“NHibernate.dll”类型的异常
在 NHibernate.Hql.Ast.ANTLR.QuerySyntaxException 中第一次偶然出现的“NHibernate.dll”类型的异常

simon_li的主页 simon_li | 初学一级 | 园豆:182
提问于:2012-06-16 16:06
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册