• NHibernate Tips


    Nhibernate mapping config file build action

    One of the most common mistakes in mapping is forgetting to set the build action to Embedded Resource. This leads to the "No Persister for class"

    MappingException.

    Avoid redundant mappings

    Don't declare the column name, rules or constrain which is specified just as the Nhibernate does. Such as:

         1) The property name is the same as column name of the mapping table

         2) Every property in Nhibernate which is declared not-null="false" as default


    Use natural key to present the identification in real world

    <natural-id mutable="true">

    <property name="UserName" not-null="true" />

    </natural-id>

    There is property for natural-id element, "mutable" whose default value is false; if you change value of the natural key or keys from time to time, please set this value to true.

    Use surrogate key for Identification of the physical record in the database.
    Lazy Loading requirements

         1) The class to be lazy loaded cannot be a sealed class
         2) The class must have a protected or public constructor without parameter
         3) All public members of the class must be virtual, includes the method

    NH Features and Add on

    • NH Validator
    • NH Spatial
    • Components (complex-types)
    • Fluent NHibernate & HBM XML: generate hbm xml mapping files or Fluent NHibernate code.
    • All NHibernate options (bytecode generator etc.)


  • 相关阅读:
    shell编程之 ()[] {}
    mysql环境搭建
    CSS布局基础——BFC
    Java线程
    chrome developer tool—— 断点调试篇
    JavaScript技巧[转载]
    如何在github中创建演示demo
    rem在响应式布局中的应用
    javascript模块化
    浏览器客户端的数据存储
  • 原文地址:https://www.cnblogs.com/haokaibo/p/2156544.html
Copyright © 2020-2023  润新知