NHibernate Forge
The official new home for the NHibernate for .NET community

NHibernate Documentation Structure Proposal

Article
Comments (9)
History (10)
100% of people found this useful

NHibernate Documentation Structure Proposal

This is a proposal for a new structure of the NHibernate reference documentation. The goal is to discuss it and get some feedback from the community.

Goals

The goals of the restructuring of the documentation are:

  • move from "feature oriented" to "solution oriented". For instance, instead of having a chapter about the "version" xml element, there is a chapter about "concurrency". So the reader has a problem to solve, and he finds a chapter that explains, how NH solves it. The reader can't know that he needs a version element. Such a chapter should cover all elements of a certain problem, in the given example this are the version xml-element, the optimistic-lock xml-attribute of classes and properties, explicit version increment, locking and so on.
  • Additionally, there shall be a complete reference of the mappings, configurations and others in an appendix that links to the chapters.
  • More diagrams for mapping strategies
  • More best practices and patterns
  • Fill gaps where the documentation is not complete (enough), for instance special HQL features, user types, interceptors and events, connection factories and other extensions, (new) proxy factories etc.

Structure

Part 1: First Steps

In this part: a high-level overview of the whole picture.

Quick start

  • simple program that runs "out of the box"
  • not too much code, not too much explanation (but links to chapters)
  • includes inheritance, reference, list
  • includes schema generation
  • includes some simple hql
  • includes configuration for sqlserver, oracle, mysql

Architecture and basic concepts

  •  Architecture (diagrams)
  •  "Factory-Chain" Configuration => SessionFactory => Session => Transaction / Query
  •  Instance States
  •  Session Cache (see also "Working with persistent objects")
  •  Application Architectures (referenced assemblies from application layers)

Setting Up

  • Three ways: nhibernate.cfg.xml, app.config, programmatic
  • Dialects and Drivers (See also Appendix "full list of Drivers / Dialects")
  • ProxyFactory configuration (see "lazy loading")
  • SessionProvider, contextual sessions
  • Getting a connection (connection provider, user provided, connection release mode)
  • How to set up a Project, minimal program
    • configuration file
    • mapping files (see "OR Mapping Basics")

Part 2: Writing and Mapping Classes

In this part: Static view, classes, mappings, db schema

Persistent classes

  • Example poco, basic rules
  • Object Identity
    • id generators
    • best practices
    • composite keys (see also "Working with legacy databases")
    • component keys (see also "Working with legacy databases")
  • Overriding Equals and GetHashCode
  • Optional: Version (see optimistic locking)
  • lifecycle callbacks
  • validation
  • see also: lazy loading (because of virtual)

OR Mapping Basics

  • Manage mapping files
    • as xml files
    • as embedded resources
    • modular mapping files
    • alternatives (attributes, FNH)
  • Using quoted identifiers
    • NH Types (see also: "Extend NH behaviour - user types", Appendix "Full List of Types")
  • Naming conventions
  • Property / field (access strategy)

Mapping primitive values and single ended references

  • properties
  • references many-to-one
  • references one-to-one
  • map several classes to one table: components
  • dynamic components
  • map a class to several tables: join
  • any types

Mapping Collections

  • persistent collections
  • set, list, map, bag, array, primitive-array
  • one-to-many relations
  • many-to-many relations
  • composite-elemements
  • collection performance
  • Sorted collections

Mapping Inheritance

  • Table per Hierarchy
  • Table per Concrete Class
  • Table per Class
  • Mixing strategies

Mapping to legacy databases

  • composite keys
  • component keys
  • property-ref

Generating The Database

  • The schema export tool
  • not null
  • foreign keys
  • indexes
  • unique keys
  • Auxiliary Database Objects

mapping file generation from entity

Part 3: Working with Persistent Objects

In this part: Dynamic view, sessions, queries, modifications, transactions etc.

Working with sessions

  • sessions, session cache, flushing
  • cascading
  • detached objects, reattaching

Querying

  • Introduction, when to use which kind of query

HQL Queries

  • Syntax
  • Multi Query

Criteria Queries

  • API
  • Multi Criteria

Using NH filters

Lazy loading and fetching strategies

  • fetching strategies
  • collections
  • references (proxies)
  • load
  • Utility.Initialize
  • batch fetching

Updating and deleting

  • updating, batch-updates, HQL updates
  • deleting, one-shot-delete, HQL delete

Transactions And Concurrency

  • Transaction factory (see also: setting up)
  • Concurrency
    • Optimistic Locking
      • Version columns
      • Property level
      • Force version increment
      • application version check
    • Pessimistic Locking

Part 4: Enhanced Features

In this part: Features that are not used by everyone. They are not important to understand to work with NH.

Using Native SQL

  • Sql queries
  • custom SQL for query/update/insert/delete
  • precompiled queries
  • Using SP's, db functions and triggers
    • property update/insert
    • property generated
    • property formula
    • see also: "Generating The Database - Auxiliary Database Objects"
  • Using Database Views

Caches

  • second level cache
  • query cache

Meta API

Extend NH behaviour

  • user types
  • Interceptors
  • events
  • connection provider
  • transaction factory
  • session provider

Part 5: Examples

In this part: examples

Appendix

In this part: lists and references. The references (eg. mapping xml elements, dialects etc are important to find the documentation. So there are basically only links to chapters)

Trouble shooting

Configuration Reference

  • Getting a connection (connection provider, user provided) (setting up)
  • proxy generator (lazy loading)
  • cache configuration (optimizing)
  • Transaction factory (setting up)
  • Dialects (setting up)
  • Outer join fetching (lazy loading?)
  • logging (trouble shooting)
  • naming strategy (mapping)

Full List of Dialiects


Full List of Drivers

XML-Mapping full reference

Full List of Type

On the other hand if you intend to produce a large amount of Screen Printing Machine items, you will have to invest in the industry.

Recent Comments

By: benhyrman Posted on 06-09-2009 12:20

I would love to help proof and maybe contribute. Also, you should add DetachedCriteria to the Criteria section (I only saw Criteria/Multicriteria)

I would weave in non-core topics as "asides" or sidebars in the documentation. There is a lot of stuff in NHContrib, uNHAddins and FNH (not to mention the Lambda Criteria code) that many users might find useful... but you don't want to make it look like it's part of the NH core (maybe put detailed coverage in a separate appendix per project?)

By: Stefan Steinegger Posted on 06-04-2009 17:41

@Diego: Right now I think it's doable. I don't think that the community will do the work for me, this is a major mistake when starting an open source project. But I hope when I built up the structure, that some people will help. As soon as one can see what's there, you also can easily see what's missing, and then it's easy to fix.

Your contribution will be much appreciated. But don't be disappointed if you don't hear anything from me in the next time, because the first steps I have to do myself. Of course, feedback to the structure proposal and my blogs is quite important. Later I will write the "how to contribute" and contact the people and hope for some active contribution.

By: Diego Posted on 06-04-2009 13:56

@Stefan:

I absolutely agree with you :-) So many little pieces that should be all together. Excuse me if you feel that my post was pessimistic, I'm from Spain and my English is just not good enough to express emotions :-)

I just tried to tell that there is a potential risk that the project will be abandoned miserably because of lack of help from community and/or lack of positive feedback. And because of its dimension, of course.

And about NHiA book, I think that your first goal: "move from feature oriented to solution oriented" is more or less similar to that the book tries to solve. But anyway, come on, if you (with community help) can write a manual/book more solution oriented I think it is a VERY WELCOME addition to the NH code. And of course would be a lot more in sync with the actual code (NHiA is written after v1.2.1).

So, I think your idea is fantastic (I hope this enthusiastic beginning lasts) and I really would like to help you with my little spare time. I am looking forward for your article about "How to help with Documentation". I knew that you already started with this, but I still don't know how to help :-)

By: Stefan Steinegger Posted on 06-02-2009 18:58

@s.rottem: I discussed the DocBook-or-Wiki question with Fabio before I started. I favored the ability of creating clean, printable PDF (with toc, index etc) and HTML at the same time to the everyone-can-contribute approach. By the way, everyone can still contribute to DocBook the same way as to the source code, you just need Tortoise and an XML editor. I will write a "How to contribute to the docs".

I tried to format the toc to highlights the parts, but I didn't succeed. The configuration is roughly working fine, but I would like to fix small things (like page breaks after a title or in the middle of table rows) and make it visually more appealing (colors, fonts, logo etc). The reference doc look like from the eighties. It's not important, but you know, pretty things are always more enjoyable. :-)

By: s.rottem Posted on 06-02-2009 18:35

I think the structure looks good for a first draft.  It's going to be a long slog, so keep your head up.

I've had some experience with DocBook transformations and HTML - I did some work on trying to restructure the Monorail docs into DocBook (www.symbiotic-development.com/.../html) - people didn't seem to like that much at the time as the crowd seemed to prefer the wiki everyone-can-contribute approach.  It's still sitting on my backburner...

Drop me a line if you need any assistance with the transforms.

View All
Powered by Community Server (Commercial Edition), by Telligent Systems