May 29, 2010
@ 10:55 PM
  Criteria Weighting NHibernate iBatis
F1 I don't have any control of my database design/schema 4 2 5
F2 I am driven by the relational data model because I am working with a legacy database 5 3 5
F3 My database schema will not be changing due to an already implemented data structure 3 4 5
F4 My primary keys are composite natural keys which are complex 4 1 5
F5 I am very comfortable writing SQL 4 1 5
F6 I want a tool to generate the CRUD for me 3 5 1
F7 I do not require complex queries that join more than one table 4 5 1
F8 I need a good user community 1 5 1
F9 I have deadlines that are in the distant future 1 5 1
F10 I want a free tool 2 5 5
Score 90 119

iBatis right now is MyBatis, ( moved to google code

Categories: nHibernate

August 29, 2008
@ 10:41 PM
I have enabled the level2 cache for one of my old project "Asset  Management".

here are some important points to use the L2 cache:

1.  add this line to web.config nhibernate section

  <add key="hibernate.cache.provider_class"
       value="NHibernate.Caches.SysCache.SysCacheProvider,NHibernate.Caches.SysCache" />
  <add key="relativeExpiration" value="300" />

2. NHibernate.Caches.SysCache.dll have different version. it can be download from nhibernate contribution.

I didn't have one to match my nhibernate version, if you can't found the right version, you  download the source code and rebuilt it with the current nhibernate.

3. example of set entity definition file *.hbm

<class name="eg.Cat" .... >
    <cache usage="read-write"/>
    <set name="Kittens" ... >
        <cache usage="read-write"/>


There are readonly|read-write|nonstrict-read-write strategies.

readonly for entities never be modified.

nonstrict-read-write for entities  be update occasionally(don't need worry about two trsaction update same entity)


4. the query cache is not recommended, because it stateless, but good for query the "readonly"  database tables

<add key="hibernate.cache.use_query_cache" value="true" />

IList blogs = sess.CreateQuery("from Blog blog where blog.Blogger = :blogger")
    .SetEntity("blogger", blogger)

call IQuery.SetForceCacheRefresh(true) to reload the query, it is particularly if the table is updated outside of the nhibernate.
for the current Castle ActiveRecord, the nhibernate is 1.2, here is the doc:
to understand how Level2 cache working:

Hibernate: Truly Understanding the Second-Level and Query Caches


Hibernate HQL And Performance 

Categories: nHibernate

NHibernate Step by Step (一) Hello,NHibernate!


nhibernate_template.rar (9.17 KB)

for Mysql,

provide Type use ADOXSchemaProvider

connection String:

DRIVER={MySQL ODBC 3.51 Driver};;PORT=3306;DATABASE=myDatabase; USER=myUsername;PASSWORD=myPassword;OPTION=3;


test passed but generating failed..

Helpful tools related to NHibernate

  • HQL Analyzer and hbm.xml GUI Editor
  • ObjectMapper by Mats Helander is a mapping GUI with NHibernate support
  • MyGeneration is a template-based code generator GUI. Its template library includes templates for generating mapping files and classes from a database.
  • AndroMDA is an open-source code generation framework that uses Model Driven Architecture (MDA) to transform UML models into deployable components. It supports generation of data access layers that use NHibernate as their persistence framework.
  • CodeSmith Template for NH
  • NHibernate Helper Kit is a VS2005 add-in to generate classes and mapping files


Categories: nHibernate

Categories: nHibernate