zoukankan      html  css  js  c++  java
  • NHibernate学习注意点

    1.

    为Microsoft Visual Studio 2008添加编写NHibernate配置文件智能提示的功能。只要在下载的NHibernate里找到configuration.xsd和nhibernate-mapping.xsd两个文件并复制到X:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas目录即可。

    2.

    NHibernate使用属性的getter和setter来实现持久化。

    属性可设置为public、internal、protected、protected internal或private.

    要求持久化类不是sealed的,而且其公共方法、属性和事件声明为virtual

    3.

    hibernate.cfg.xml文件

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
      <session-factory name="NHFactory">
        <!-- properties -->
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
        <property name="connection.connection_string">Server=YQKC003\SQLEXPRESS;initial catalog=hotelManageDB;integrated security=sspi</property>
        <property name="show_sql">false</property>
        <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property><!--数据库方言-->
        <property name="use_outer_join">true</property>
        <!-- mapping files -->
        <mapping assembly="HotelManageModels" /><!--映射整个持久层的程序集-->
     
      </session-factory>
    </hibernate-configuration>

    完毕!

    此配置也可配置在app.config中进行或在类中

  • 相关阅读:
    drf中APIView源码分析
    将orm中模型类对象转化为字典,简单粗暴的方法
    python中uuid的使用
    每日作业 7/3
    传输文件到docker容器
    mysql 常用选项
    mysql基本语句
    mysql数据库的基本操作增删改查
    docker service的常用操作
    centos7主机重命名
  • 原文地址:https://www.cnblogs.com/zhangqifeng/p/1418914.html
Copyright © 2011-2022 走看看