NHibernate - Relational Persistence for Idiomatic .NET

NHibernate Reference Documentation

5.5


Table of Contents

Preface
1. Quick-start with IIS and Microsoft SQL Server
1.1. Getting started with NHibernate
1.2. First persistent class
1.3. Mapping the cat
1.4. Playing with cats
1.5. Finally
2. Architecture
2.1. Overview
2.2. Instance states
2.3. Contextual Sessions
3. ISessionFactory Configuration
3.1. Programmatic Configuration
3.2. Obtaining an ISessionFactory
3.3. User provided ADO.NET connection
3.4. NHibernate provided ADO.NET connection
3.5. Using a custom configuration provider
3.6. Optional configuration properties
3.6.1. SQL Dialects
3.6.2. Outer Join Fetching
3.6.3. Custom ICacheProvider
3.6.4. Query Language Substitution
3.6.5. System level optional properties
3.7. Logging
3.8. Implementing an INamingStrategy
3.9. XML Configuration File
4. Persistent Classes
4.1. A simple POCO example
4.1.1. Declare properties for persistent fields
4.1.2. Implement a default constructor
4.1.3. Provide an identifier property (optional)
4.1.4. Prefer non-sealed classes and virtual methods (optional)
4.2. Implementing inheritance
4.3. Implementing Equals() and GetHashCode()
4.4. Dynamic models
4.5. Tuplizers
4.6. Lifecycle Callbacks
4.7. IValidatable callback
5. Basic O/R Mapping
5.1. Mapping declaration
5.1.1. XML Namespace
5.1.2. hibernate-mapping
5.1.3. class
5.1.4. subselect
5.1.5. id
5.1.5.1. generator
5.1.5.2. Hi/Lo Algorithm
5.1.5.3. UUID Hex Algorithm
5.1.5.4. UUID String Algorithm
5.1.5.5. GUID Algorithms
5.1.5.6. Identity columns and Sequences
5.1.5.7. Assigned Identifiers
5.1.5.8. Primary keys assigned by triggers
5.1.5.9. Enhanced identifier generators
5.1.6. composite-id
5.1.7. discriminator
5.1.8. version (optional)
5.1.9. timestamp (optional)
5.1.10. property
5.1.11. many-to-one
5.1.12. one-to-one
5.1.13. natural-id
5.1.14. component, dynamic-component
5.1.15. properties
5.1.16. subclass
5.1.17. joined-subclass
5.1.18. union-subclass
5.1.19. join
5.1.20. key
5.1.21. column and formula elements
5.1.22. map, set, list, bag
5.1.23. import
5.1.24. any
5.2. NHibernate Types
5.2.1. Entities and values
5.2.2. Basic value types
5.2.3. Custom value types
5.3. Mapping a class more than once
5.4. SQL quoted identifiers
5.5. Modular mapping files
5.6. Generated Properties
5.7. Auxiliary Database Objects
5.8. Meta data
6. Collection Mapping
6.1. Persistent Collections
6.2. Mapping a Collection
6.2.1. Collection foreign keys
6.2.2. Collection elements
6.2.3. Indexed collections
6.2.4. Collections of Values and Many-To-Many Associations
6.2.5. One-To-Many Associations
6.3. Advanced collection mappings
6.3.1. Sorted Collections
6.3.2. Bidirectional Associations
6.3.3. Bidirectional associations with indexed collections
6.3.4. Ternary Associations
6.3.5. Using an <idbag>
6.3.6. Heterogeneous Associations
6.4. Lazy Initialization
6.5. Collection examples
7. Association Mappings
7.1. Introduction
7.2. Unidirectional associations
7.2.1. Many-to-one
7.2.2. One-to-one
7.2.3. One-to-many
7.3. Unidirectional associations with join tables
7.3.1. One-to-Many
7.3.2. Many-to-one
7.3.3. One-to-one
7.3.4. Many-to-many
7.4. Bidirectional associations
7.4.1. One-to-many / many-to-one
7.4.2. One-to-one
7.5. Bidirectional associations with join tables
7.5.1. One-to-many / many-to-one
7.5.2. One-to-one
7.5.3. Many-to-many
7.6. More complex association mappings
8. Component Mapping
8.1. Dependent objects
8.2. Collections of dependent objects
8.3. Components as IDictionary indices
8.4. Components as composite identifiers
8.5. Dynamic components
9. Inheritance Mapping
9.1. The Three Strategies
9.1.1. Table per class hierarchy
9.1.2. Table per subclass
9.1.3. Table per subclass, using a discriminator
9.1.4. Mixing table per class hierarchy with table per subclass
9.1.5. Table per concrete class
9.1.6. Table per concrete class, using implicit polymorphism
9.1.7. Mixing implicit polymorphism with other inheritance mappings
9.2. Limitations
10. Manipulating Persistent Data
10.1. Creating a persistent object
10.2. Loading an object
10.3. Querying
10.3.1. Scalar queries
10.3.2. The IQuery interface
10.3.3. Filtering collections
10.3.4. Criteria queries
10.3.5. Queries in native SQL
10.4. Updating objects
10.4.1. Updating in the same ISession
10.4.2. Updating detached objects
10.4.3. Reattaching detached objects
10.5. Deleting persistent objects
10.6. Flush
10.7. Checking dirtiness
10.8. Ending a Session
10.8.1. Flushing the Session
10.8.2. Committing the database transaction
10.8.3. Closing the ISession
10.9. Exception handling
10.10. Lifecycles and object graphs
10.11. Interceptors
10.12. Metadata API
11. Read-only entities
11.1. Making persistent entities read-only
11.1.1. Entities of immutable classes
11.1.2. Loading persistent entities as read-only
11.1.3. Loading read-only entities from an HQL query/criteria
11.1.4. Making a persistent entity read-only
11.2. Read-only affect on property type
11.2.1. Simple properties
11.2.2. Unidirectional associations
11.2.2.1. Unidirectional one-to-one and many-to-one
11.2.2.2. Unidirectional one-to-many and many-to-many
11.2.3. Bidirectional associations
11.2.3.1. Bidirectional one-to-one
11.2.3.2. Bidirectional one-to-many/many-to-one
11.2.3.3. Bidirectional many-to-many
12. Transactions And Concurrency
12.1. Configurations, Sessions and Factories
12.2. Threads and connections
12.3. Considering object identity
12.4. Optimistic concurrency control
12.4.1. Long session with automatic versioning
12.4.2. Many sessions with automatic versioning
12.4.3. Customizing automatic versioning
12.4.4. Application version checking
12.5. Session disconnection
12.6. Pessimistic Locking
12.7. Connection Release Modes
12.8. Transaction scopes (System.Transactions)
13. Interceptors and events
13.1. Interceptors
13.2. Event system
14. Batch processing
14.1. Batch inserts
14.2. The StatelessSession interface
14.3. DML-style operations
15. HQL: The Hibernate Query Language
15.1. Case Sensitivity
15.2. The from clause
15.3. Associations and joins
15.4. The select clause
15.5. Aggregate functions
15.6. Polymorphic queries
15.7. The where clause
15.8. Expressions
15.9. The order by clause
15.10. The group by clause
15.11. Sub-queries
15.12. HQL examples
15.13. Tips & Tricks
16. Criteria Queries
16.1. Creating an ICriteria instance
16.2. Narrowing the result set
16.3. Ordering the results
16.4. Associations
16.5. Join entities without association (Entity joins or ad hoc joins)
16.6. Dynamic association fetching
16.7. Example queries
16.8. Projections, aggregation and grouping
16.9. Detached queries and sub-queries
17. QueryOver Queries
17.1. Structure of a Query
17.2. Simple Expressions
17.3. Additional Restrictions
17.4. Associations
17.5. Join entities without association (Entity joins or ad hoc joins)
17.6. Aliases
17.7. Projections
17.8. Projection Functions
17.9. Entities Projection
17.10. Sub-queries
18. Linq Queries
18.1. Structure of a Query
18.2. Parameter types
18.3. Supported methods and members
18.3.1. Common methods
18.3.2. DateTime and DateTimeOffset
18.3.3. ICollection, non generic and generic
18.3.4. IDictionary, non generic and generic
18.3.5. Mathematical functions
18.3.6. Nullables
18.3.7. Strings
18.4. Future results
18.5. Fetching associations
18.6. Modifying entities inside the database
18.6.1. Inserting new entities
18.6.2. Updating entities
18.6.3. Deleting entities
18.7. Query cache
18.8. Extending the Linq to NHibernate provider
18.8.1. Adding SQL functions
18.8.2. Adding a custom generator
19. Native SQL
19.1. Using an ISQLQuery
19.1.1. Scalar queries
19.1.2. Entity queries
19.1.3. Handling associations and collections
19.1.4. Returning multiple entities
19.1.4.1. Alias and property references
19.1.5. Returning non-managed entities
19.1.6. Handling inheritance
19.1.7. Parameters
19.2. Named SQL queries
19.2.1. Using return-property to explicitly specify column/alias names
19.2.2. Using stored procedures for querying
19.2.2.1. Rules/limitations for using stored procedures
19.3. Custom SQL for create, update and delete
19.4. Custom SQL for loading
20. Filtering data
20.1. NHibernate filters
21. Improving performance
21.1. Fetching strategies
21.1.1. Working with lazy associations
21.1.2. Tuning fetch strategies
21.1.3. Single-ended association proxies
21.1.4. Initializing collections and proxies
21.1.5. Using batch fetching
21.1.6. Using subselect fetching
21.2. The Second Level Cache
21.2.1. Cache mappings
21.2.2. Strategy: read only
21.2.3. Strategy: read/write
21.2.4. Strategy: nonstrict read/write
21.2.5. Strategy: never
21.3. Managing the caches
21.4. The Query Cache
21.5. Understanding Collection performance
21.5.1. Taxonomy
21.5.2. Lists, maps, idbags and sets are the most efficient collections to update
21.5.3. Bags and lists are the most efficient inverse collections
21.5.4. One shot delete
21.6. Batch updates
21.7. Query batch
21.8. Future results
22. Toolset Guide
22.1. Schema Generation
22.1.1. Customizing the schema
22.1.2. Running the tool
23. Example: Parent/Child
23.1. A note about collections
23.2. Bidirectional one-to-many
23.3. Cascading lifecycle
23.4. Using cascading Update()
23.5. Conclusion
24. Example: Weblog Application
24.1. Persistent Classes
24.2. NHibernate Mappings
24.3. NHibernate Code
25. Example: Various Mappings
25.1. Employer/Employee
25.2. Author/Work
25.3. Customer/Order/Product
25.4. Miscellaneous example mappings
25.4.1. "Typed" one-to-one association
25.4.2. Composite key example
25.4.3. Many-to-many with shared composite key attribute
25.4.4. Content based discrimination
25.4.5. Associations on alternate keys
26. Best Practices
I. NHibernateContrib Documentation
Preface
27. NHibernate.Caches
27.1. How to use a cache?
27.2. Using a custom configuration provider
27.3. Prevalence Cache Configuration
27.4. SysCache Configuration
27.5. SysCache2 Configuration
27.5.1. Table-based Dependency
27.5.2. Command-Based Dependencies
27.5.3. Aggregate Dependencies
27.5.4. Additional Settings
27.6. EnyimMemcached Configuration
27.7. RtMemoryCache Configuration
27.8. NHibernate.Caches.StackExchangeRedis Configuration
27.9. CoreMemoryCache Configuration
27.10. CoreDistributedCache Configuration
27.10.1. Memcached distributed cache factory
27.10.2. Redis distributed cache factory
27.10.3. SQL Server distributed cache factory
27.10.4. Memory distributed cache factory
28. NHibernate.Mapping.Attributes
28.1. What's new?
28.2. How to use it?
28.3. Tips
28.4. Known issues and TODOs
28.5. Developer Notes