Dashboard > ActiveRecord > ... > Documentation > Active Record Internals
Active Record Internals
Added by Tim Haines, last edited by Daniel Rothmaler on Aug 20, 2007  (view change)
Labels: 
(None)


How it works

The ActiveRecord framework collects information about your classes, tries to infer some meaning and generates the correct mapping for NHibernate. By doing this, ActiveRecord does not require that you make everything explicit, thus saving your time.

ActiveRecord also hides some complexity in favor of more natural code, which you will see in the next following sections.

How it handles mappings

When you invoke ActiveRecordStarter.Initialize, the framework will inspect the set of types. As a matter of fact it uses the ActiveRecordModelBuilder, which creates a ActiveRecordModel that has all information about the type (primary key, mapped properties, relations, validations and so on).

After that ActiveRecordStarter executes visitors on the set of ActiveRecordModel just created. Each visitor is concerned about some specific task.

  • GraphConnectorVisitor: connects the types based on relation information, like connection Blog to Post. This makes some tasks simpler later
  • SemanticVerifierVisitor: based on the information on the model, validates it and throw exception with clear messages whenever something is not right.
  • XmlGenerationVisitor: generates the Xml expected by NHibernate

How scopes work

TODO

Reference Articles

Hammett has two blog posts explaining how Active Record works internally:

Site running on a free Atlassian Confluence Community License granted to Castle Project. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators