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.)


  • 相关阅读:
    基于协同过滤的个性化Web推荐
    自动推荐系统效果为什么不好
    基于模糊聚类和协同过滤的混合推荐系统
    海量数据处理之蓄水池抽样算法
    心灵启发--不羡慕别人的生活
    ubuntu安装软件整理
    Hadoop系列
    网页返回错误编号含义整理
    找出单链表的中间位置指针
    【python爬虫】根据查询词爬取网站返回结果
  • 原文地址:https://www.cnblogs.com/haokaibo/p/2156544.html
Copyright © 2011-2022 走看看