NHibernate - Relational Persistence for Idiomatic .NET

NHibernate Reference Documentation

5.0


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. Optional configuration properties
3.5.1. SQL Dialects
3.5.2. Outer Join Fetching
3.5.3. Custom ICacheProvider
3.5.4. Query Language Substitution
3.6. Logging
3.7. Implementing an INamingStrategy
3.8. 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. 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. map, set, list, bag
5.1.21. import
5.2. NHibernate Types
5.2.1. Entities and values
5.2.2. Basic value types
5.2.3. Custom value types
5.2.4. Any type mappings
5.3. SQL quoted identifiers
5.4. Modular mapping files
5.5. Generated Properties
5.6. Auxiliary Database Objects
6. Collection Mapping
6.1. Persistent Collections
6.2. Mapping a Collection
6.3. Collections of Values and Many-To-Many Associations
6.4. One-To-Many Associations
6.5. Lazy Initialization
6.6. Sorted Collections
6.7. Using an <idbag>
6.8. Bidirectional Associations
6.9. Bidirectional associations with indexed collections
6.10. Ternary Associations
6.11. Heterogeneous Associations
6.12. Collection examples
7. Component Mapping
7.1. Dependent objects
7.2. Collections of dependent objects
7.3. Components as IDictionary indices
7.4. Components as composite identifiers
7.5. Dynamic components
8. Inheritance Mapping
8.1. The Three Strategies
8.1.1. Table per class hierarchy
8.1.2. Table per subclass
8.1.3. Table per subclass, using a discriminator
8.1.4. Mixing table per class hierarchy with table per subclass
8.1.5. Table per concrete class
8.1.6. Table per concrete class, using implicit polymorphism
8.1.7. Mixing implicit polymorphism with other inheritance mappings
8.2. Limitations
9. Manipulating Persistent Data
9.1. Creating a persistent object
9.2. Loading an object
9.3. Querying
9.3.1. Scalar queries
9.3.2. The IQuery interface
9.3.3. Filtering collections
9.3.4. Criteria queries
9.3.5. Queries in native SQL
9.4. Updating objects
9.4.1. Updating in the same ISession
9.4.2. Updating detached objects
9.4.3. Reattaching detached objects
9.5. Deleting persistent objects
9.6. Flush
9.7. Ending a Session
9.7.1. Flushing the Session
9.7.2. Committing the database transaction
9.7.3. Closing the ISession
9.8. Exception handling
9.9. Lifecycles and object graphs
9.10. Interceptors
9.11. Metadata API
10. Read-only entities
10.1. Making persistent entities read-only
10.1.1. Entities of immutable classes
10.1.2. Loading persistent entities as read-only
10.1.3. Loading read-only entities from an HQL query/criteria
10.1.4. Making a persistent entity read-only
10.2. Read-only affect on property type
10.2.1. Simple properties
10.2.2. Unidirectional associations
10.2.2.1. Unidirectional one-to-one and many-to-one
10.2.2.2. Unidirectional one-to-many and many-to-many
10.2.3. Bidirectional associations
10.2.3.1. Bidirectional one-to-one
10.2.3.2. Bidirectional one-to-many/many-to-one
10.2.3.3. Bidirectional many-to-many
11. Transactions And Concurrency
11.1. Configurations, Sessions and Factories
11.2. Threads and connections
11.3. Considering object identity
11.4. Optimistic concurrency control
11.4.1. Long session with automatic versioning
11.4.2. Many sessions with automatic versioning
11.4.3. Customizing automatic versioning
11.4.4. Application version checking
11.5. Session disconnection
11.6. Pessimistic Locking
11.7. Connection Release Modes
11.8. Transaction scopes (System.Transactions)
12. Interceptors and events
12.1. Interceptors
12.2. Event system
13. Batch processing
13.1. Batch inserts
13.2. The StatelessSession interface
13.3. DML-style operations
14. HQL: The Hibernate Query Language
14.1. Case Sensitivity
14.2. The from clause
14.3. Associations and joins
14.4. The select clause
14.5. Aggregate functions
14.6. Polymorphic queries
14.7. The where clause
14.8. Expressions
14.9. The order by clause
14.10. The group by clause
14.11. Sub-queries
14.12. HQL examples
14.13. Tips & Tricks
15. Criteria Queries
15.1. Creating an ICriteria instance
15.2. Narrowing the result set
15.3. Ordering the results
15.4. Associations
15.5. Dynamic association fetching
15.6. Example queries
15.7. Projections, aggregation and grouping
15.8. Detached queries and sub-queries
16. QueryOver Queries
16.1. Structure of a Query
16.2. Simple Expressions
16.3. Additional Restrictions
16.4. Associations
16.5. Aliases
16.6. Projections
16.7. Projection Functions
16.8. Sub-queries
17. Linq Queries
17.1. Structure of a Query
17.2. Parameter types
17.3. Supported methods and members
17.3.1. Common methods
17.3.2. DateTime and DateTimeOffset
17.3.3. ICollection, non generic and generic
17.3.4. IDictionary, non generic and generic
17.3.5. Mathematical functions
17.3.6. Nullables
17.3.7. Strings
17.4. Future results
17.5. Fetching associations
17.6. Modifying entities inside the database
17.6.1. Inserting new entities
17.6.2. Updating entities
17.6.3. Deleting entities
17.7. Query cache
17.8. Extending the Linq to NHibernate provider
17.8.1. Adding SQL functions
17.8.2. Adding a custom generator
18. Native SQL
18.1. Using an ISQLQuery
18.1.1. Scalar queries
18.1.2. Entity queries
18.1.3. Handling associations and collections
18.1.4. Returning multiple entities
18.1.4.1. Alias and property references
18.1.5. Returning non-managed entities
18.1.6. Handling inheritance
18.1.7. Parameters
18.2. Named SQL queries
18.2.1. Using return-property to explicitly specify column/alias names
18.2.2. Using stored procedures for querying
18.2.2.1. Rules/limitations for using stored procedures
18.3. Custom SQL for create, update and delete
18.4. Custom SQL for loading
19. Filtering data
19.1. NHibernate filters
20. Improving performance
20.1. Fetching strategies
20.1.1. Working with lazy associations
20.1.2. Tuning fetch strategies
20.1.3. Single-ended association proxies
20.1.4. Initializing collections and proxies
20.1.5. Using batch fetching
20.1.6. Using subselect fetching
20.2. The Second Level Cache
20.2.1. Cache mappings
20.2.2. Strategy: read only
20.2.3. Strategy: read/write
20.2.4. Strategy: nonstrict read/write
20.3. Managing the caches
20.4. The Query Cache
20.5. Understanding Collection performance
20.5.1. Taxonomy
20.5.2. Lists, maps, idbags and sets are the most efficient collections to update
20.5.3. Bags and lists are the most efficient inverse collections
20.5.4. One shot delete
20.6. Batch updates
20.7. Multi Query
20.8. Multi Criteria
21. Toolset Guide
21.1. Schema Generation
21.1.1. Customizing the schema
21.1.2. Running the tool
22. Example: Parent/Child
22.1. A note about collections
22.2. Bidirectional one-to-many
22.3. Cascading lifecycle
22.4. Using cascading Update()
22.5. Conclusion
23. Example: Weblog Application
23.1. Persistent Classes
23.2. NHibernate Mappings
23.3. NHibernate Code
24. Example: Various Mappings
24.1. Employer/Employee
24.2. Author/Work
24.3. Customer/Order/Product
25. Best Practices
I. NHibernateContrib Documentation
Preface
26. NHibernate.Caches
26.1. How to use a cache?
26.2. Prevalence Cache Configuration
26.3. SysCache Configuration
26.4. SysCache2 Configuration
26.4.1. Table-based Dependency
26.4.2. Command-Based Dependencies
26.4.3. Aggregate Dependencies
26.4.4. Additional Settings
26.5. RtMemoryCache Configuration
27. NHibernate.Mapping.Attributes
27.1. What's new?
27.2. How to use it?
27.3. Tips
27.4. Known issues and TODOs
27.5. Developer Notes