﻿---
title: SAIF.Data.NHibernate overview
summary: High-level purpose, scope, and responsibilities for this library.
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data.NHibernate
reference_type: package
---

# SAIF.Data.NHibernate overview

> **Documentation context:** Packaged Component (NuGet)

SAIF.Data.NHibernate is the FluentNHibernate persistence layer for `SAIF.Data`'s entity models. It compiles 388 FluentNHibernate ClassMaps over roughly 367 distinct tables (mostly Oracle `WCIS_DBA` schema tables, plus one SQL Server stored procedure), 11 custom NHibernate `IUserType` conversions, and 12 specialized repositories that implement query and command behavior on top of the repository interfaces declared in `SAIF.Data`.

## Purpose
- Provide the object-relational mapping and repository implementations that let `SAIF.Data` and its consumers (`SAIF.Services`, various `DependencyMaps` web/console entry points) read and write SAIF's Oracle-hosted claims, policy, collections, imaging, and EDI data through NHibernate, without owning session, transaction, or connection-string management itself.
- Encapsulate a small number of legacy Oracle PL/SQL package calls (via embedded `.hbm.xml` named queries and inline `CreateSqlQuery`) and one SQL Server stored procedure call behind idiomatic repository methods.

## Responsibilities
- Map SAIF.Data entities to their underlying tables through FluentNHibernate `ClassMap<T>`/`SubclassMap<T>` declarations, discovered by assembly scanning.
- Define embedded `.hbm.xml` named queries (24 defined, 21 used) and inline `CreateSqlQuery` calls (6) that invoke Oracle `WCIS_DBA` PL/SQL packages and one SQL Server stored procedure.
- Implement custom `IUserType` conversions for tri-state flags and coded enumerations under `CustomTypes/`.
- Implement 12 specialized repositories (`ClaimBillEntryRepository`, `CollectionsRepository`, `PoliciesRepository`, `PolicyPeriodPayrollAuditRepository`, `ProvidersRepository`, `ClaimScoreRepository`, `MissingTimeLossRepository`, `GroupImageRepository`, `GroupRepository`, `ImageCategoryCodeRepository`, `InvestigationRepositoryExtensions`, `PolicyOutputDocumentRepository`/`PolicyOutputDocumentExtensions`) that layer domain-specific queries over the external unit-of-work infrastructure.

## Key components
- `Mappings/`: ~390 compiled ClassMap files (388 producing ClassMaps) plus 5 embedded `.hbm.xml` files holding only `<sql-query>` named queries and their result mappings.
- `CustomTypes/`: 11 `IUserType` implementations, including `YesNoNullUserType` and the certificate/claim-authority enumerations.
- `Repositories/`: the 12 specialized repository classes and extension sets, grouped under `Groups/`, `Imaging/`, `Investigations/`, and `OutputDocuments/` sub-namespaces.
- Session/transaction management is delegated entirely to the external `SAIF.Framework.Data.NHibernate` package; this library never constructs an `ISessionFactory` or connection string itself.

## Related documentation
- [Index](index.md)
- [Architecture](architecture.md)
- [Dependencies](dependencies.md)
- [Operations and processes](operations-processes.md)
- [Business rules](business-rules.md)
- [Database tables](database-tables.md)
- [SQL catalog](sql/index.md)
- [Procedures](procedures/index.md)
- [Security and authorization](security-authorization.md)
- [API reference](api/index.md)

## Sources
- `Data/SAIF.Data.NHibernate/SAIF.Data.NHibernate.csproj`
