zoukankan      html  css  js  c++  java
  • 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.)


  • 相关阅读:
    系统设计的一些原则
    分层开发思想与小笼包
    工作与生活
    Microsoft .NET Pet Shop 4 架构与技术分析
    用人之道(二) 如何管理软件开发团队
    也谈很多开发人员的毛病
    《3S新闻周刊》第10期,本期策划:“超女”营销带来的启示
    浅析ArcIMS
    MapX的坐标问题
    应用ArcIMS构建GMap风格的地图应用
  • 原文地址:https://www.cnblogs.com/haokaibo/p/2156544.html
Copyright © 2011-2022 走看看