zoukankan      html  css  js  c++  java
  • [Study Note] Patterns and Practices in NHibernate

    NHibernate Forge 上,Patterns&Practices 栏目里面只有两篇文章,我感兴趣的是其中一篇:NHibernate and the Unit of Work Pattern

    [Identity Field, Equality and Hash Code]

    “The identity field saves a database ID field in an object to maintain identity between an in-memory object and a database row.” – Martin Fowler, PoEAA

    The surrogate key is not derived from application data.

    GUID, global unique identifier

    A Set is a collection that contains no duplicate elements.

    a object should never ever change it’s hash code during its life, that is from the moment the object is instantiated until it is disposed.

    [NHibernate and the Unit of Work Pattern]

    Part 1

    Unit of Work Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems. – Martin Fowler, PEAA

    When you’re pulling data in and out of a database, it’s important to keep track of what you’ve changed; otherwise, that data won’t be written back into the database. Similarly you have to insert new objects you create and remove any objects you delete.

    A Unit of Work keeps track of everything you do during a business transaction that can affect the database. When you’re done, if figures out everything that needs to be done to alter the database as a result of your work.

    In NHibernate, the Session object is a Unit of Work (UoW) container…Only when flushing the session will the database be alered.

    看完之后才发现这个 Unit of Work 的实现过于的复杂,至少现在我还不能完全的理解其中的奥妙。最近几天看到了大概一共三个 Unit of Work 的实现,繁简不一,有时间的话可以比较一下。

  • 相关阅读:
    JavaScript 消息框
    DOM事件
    修改输入框placeholder文字默认颜色-webkit-input-placeholder
    css—文字渐变色
    css—各浏览器下的背景色渐变
    $.ajax()方法详解
    使用meta实现页面的定时刷新或跳转
    python的连接mysql的安装
    django安装
    速查
  • 原文地址:https://www.cnblogs.com/zhaorui/p/20100406_Patterns_in_NHibernate.html
Copyright © 2011-2022 走看看