NHibernate in Action 2.2 Understanding the architecture
2011-07-30 16:05
357 查看
NH API in a layered architecture
![](http://images.cnblogs.com/cnblogs_com/sunshinefly128/201107/201107301604437738.png)
包含那么几个部分:
被Application调用执行CRUD的接口。包含 ISession, ITransaction, IQuery, ICriteria.
配置NH的结构。 包含Configuration
允许Application回调响应NHibernate内部事件的部分,比如IInterceptor, ILifecycle, iValidateble. 这一部分是对Entity中的Field或者Property的一些变化进行的响应,猜应该有 NewObject, DeleteObject, UpdateObject , Update Field等事件的响应,是实现业务规则的重要地方。
允许扩展NH的Mapping功能的部分。比如IUserType, ICompositeUserType, IIdentifierGenerator。
另外NH的基础还是ADO.net, 作者也提到:
NHibernate makes use of existing .net apis, including ADO.net and its ITransaction API. ADO.net provides a rudimentary level of abstraction of functionality common to relational databases, letting NHibernate support almost any database with ADO.net driver.
The core interfaces
ISession interface
负责CRUD操作, exposes NH’methods for finding, saving , updating, and deleting objects.
lightweight and inexpensive. 可以任意的Create 和 destroy的。
not thread safe.
the nh notion of a session is something between connection and transaction. it may be easier to think of a session as a cache or collection of loaded objects relating to a single unit of work. we sometimes call the ISession a persistence manager. ISession的作用应该就是一个Persistence manager, 应该说有点类似于DataSet,可以连接到数据库进行操作,也可以进行事务管理。
ISessionfactory interface
isn’t lightweight!
one sessionfactory for one database.
caches generated SQL statements and other mapping metadata that NHibernate uses at runtime.
secod-level cache. it can also hold cached data that has been read in one unit of work and which may be reused in a futrue unit of work or session . this is possible if you configure class and collection mappings to use the scond-level cache.
Configuration interface
specify the location of mapping documents
set NHibernate-specifc properties before creating the ISesionfactory
ITransaction interface
optional API.
其他的都没有说。
IQuery and ICriteria interface
IQuery uses queries written in HQL.
ICriteria lets you create and execute object-oriented criteria queries.
Callback interface
callback interface allow the application to receive a notification when somthing interesting happens to an object- for example, when an object is loaded, saved, or deleted.
the Ilifecycle and ivalidateble interface let a persistent object react to events relating to its own persistence lifecyle. the persistence lifecycle is encompassed by an object’s curd operation.
the iinterceptor interface was introduced to let the application process callbacks without forcing the persistent classes to implement nhibernate-specific APIs.
Types
一句话,进行NH和Database 之间的映射。
Extension inteface
主要是Cache,Tranaction等功能
![](http://images.cnblogs.com/cnblogs_com/sunshinefly128/201107/201107301604437738.png)
包含那么几个部分:
被Application调用执行CRUD的接口。包含 ISession, ITransaction, IQuery, ICriteria.
配置NH的结构。 包含Configuration
允许Application回调响应NHibernate内部事件的部分,比如IInterceptor, ILifecycle, iValidateble. 这一部分是对Entity中的Field或者Property的一些变化进行的响应,猜应该有 NewObject, DeleteObject, UpdateObject , Update Field等事件的响应,是实现业务规则的重要地方。
允许扩展NH的Mapping功能的部分。比如IUserType, ICompositeUserType, IIdentifierGenerator。
另外NH的基础还是ADO.net, 作者也提到:
NHibernate makes use of existing .net apis, including ADO.net and its ITransaction API. ADO.net provides a rudimentary level of abstraction of functionality common to relational databases, letting NHibernate support almost any database with ADO.net driver.
The core interfaces
ISession interface
负责CRUD操作, exposes NH’methods for finding, saving , updating, and deleting objects.
lightweight and inexpensive. 可以任意的Create 和 destroy的。
not thread safe.
the nh notion of a session is something between connection and transaction. it may be easier to think of a session as a cache or collection of loaded objects relating to a single unit of work. we sometimes call the ISession a persistence manager. ISession的作用应该就是一个Persistence manager, 应该说有点类似于DataSet,可以连接到数据库进行操作,也可以进行事务管理。
ISessionfactory interface
isn’t lightweight!
one sessionfactory for one database.
caches generated SQL statements and other mapping metadata that NHibernate uses at runtime.
secod-level cache. it can also hold cached data that has been read in one unit of work and which may be reused in a futrue unit of work or session . this is possible if you configure class and collection mappings to use the scond-level cache.
Configuration interface
specify the location of mapping documents
set NHibernate-specifc properties before creating the ISesionfactory
ITransaction interface
optional API.
其他的都没有说。
IQuery and ICriteria interface
IQuery uses queries written in HQL.
ICriteria lets you create and execute object-oriented criteria queries.
Callback interface
callback interface allow the application to receive a notification when somthing interesting happens to an object- for example, when an object is loaded, saved, or deleted.
the Ilifecycle and ivalidateble interface let a persistent object react to events relating to its own persistence lifecyle. the persistence lifecycle is encompassed by an object’s curd operation.
the iinterceptor interface was introduced to let the application process callbacks without forcing the persistent classes to implement nhibernate-specific APIs.
Types
一句话,进行NH和Database 之间的映射。
Extension inteface
主要是Cache,Tranaction等功能
相关文章推荐
- mahout in Action2.2-聚类介绍-K-means聚类算法
- [Study Note] NHibernate in Action 20100729
- Writing and Mapping classes(Chapter 3 of NHibernate In Action)
- understanding Nhibernate Hilo
- mahout in Action2.2-聚类介绍-K-means聚类算法
- ActiveMQ In Action 第二章 理解面向对象的中间件(MOM)和JMS 2.2 什么是面向消息的中间件及2.3 什么是java消息服务(JMS)
- NHibernate in Action Ch3 PoCOs
- [Study Note] NHibernate In Action 20100524
- Mahout in action 中文版-2.推荐器的介绍-2.1~2.2
- NHibernate in Action(序,前言,致谢)
- NHibernate in Action: write POCOs【Properies】【1】
- NHibernate in Action(概要)
- [Study Note] NHibernate In Action 20100521
- HNibernate报错了 XML validation error: 未声明“urn:nhibernate-mapping-2.2:nhibernate”元素。
- Understanding Lazy Loading Strategies for NHibernate(zhuan)
- Mahout in action 中文版-2.推荐器的介绍-2.1~2.2
- NHibernate in Action ch2 Hello NHibernate 读后
- jsf in action 笔记:理解组件和客户端的标识(Understanding component and client identifiers)--2008.04.09
- NHibernate in Action(第一章1.1)
- [Study Note] NHibernate In Action 20100526