Skip to content

SAIF.Data.NHibernate architecture

SAIF.Data.NHibernate is the persistence infrastructure for SAIF.Data's entity models: 388 compiled FluentNHibernate ClassMaps over roughly 367 distinct tables (mostly Oracle, plus one SQL Server procedure), 11 custom NHibernate user types, and a set of specialized repositories that implement the repository interfaces declared in SAIF.Data (saif-data-nhibernate-analysis.md).

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.

Component boundaries

  • Mappings/: approximately 390 compiled ClassMap files (388 producing ClassMaps, 13 without a Table() for named-query result mapping) 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 listed above, grouped under Groups/, Imaging/, Investigations/, and OutputDocuments/ sub-namespaces.

Interaction model

This library has no ISessionFactory construction, no Fluently.Configure(), no connection string, and no ContainerBuilder; session and transaction management are fully delegated to the external SAIF.Framework.Data.NHibernate package (NHibernateUnitOfWork, OracleUnitOfWorkFactory, OracleConfigurationFactory). Consuming applications supply this assembly as the mapping source to the framework's configuration factory — for example DependencyMaps/SAIF.DependencyMaps.Web.OnlineSupport/DependencyMap.cs passes typeof(ErrorLogMap).Assembly. Repositories receive NHibernateUnitOfWork (or IUnitOfWork for ProvidersRepository) by constructor injection and execute LINQ, named queries, or inline SQL. ClaimBillEntryRepository is a notable exception: it no longer uses its embedded named queries and instead delegates bill-queue processing to SAIF.Data's Guidewire-backed ICCClaimApiService (saif-data-nhibernate-analysis.md Architecture findings).

Architecture diagram

The following diagram shows how consumers reach the mapped Oracle/SQL Server data through this library's repositories, and the one operation that now bypasses the database entirely.

flowchart TD
    Consumer["SAIF.Services /<br>DependencyMaps"] --> Framework["SAIF.Framework.Data.NHibernate<br>session factory / NHibernateUnitOfWork"]
    Framework --> Repos["Specialized repositories<br>(Collections, Policies, GroupImage, etc.)"]
    Repos --> Maps["FluentNHibernate ClassMaps<br>(388 maps, ~367 tables)"]
    Maps --> Oracle["Oracle WCIS_DBA<br>packages and tables"]
    Repos --> SqlServer["SQL Server<br>bp_clm_segmntn_complexity_score"]
    Repos --> CCApi["SAIF.Data<br>ICCClaimApiService (bill queue)"]

Sequence diagram

The following diagram shows collection payment application, a write path that calls an Oracle package directly (OP-SDN-04).

sequenceDiagram
    participant Caller as SAIF.Services caller
    participant Repo as CollectionsRepository
    participant UoW as NHibernateUnitOfWork
    participant Oracle as Oracle WCIS_DBA package
    Caller->>Repo: ApplyPayments(caseSeqNum, paymentDate)
    Repo->>UoW: CreateSqlQuery(call WCIS_DBA.PK80010_LEGAL_COLLECTIONS.APPLYPAYMENTS)
    UoW->>Oracle: ExecuteUpdate()
    Oracle-->>UoW: Rows affected
    UoW-->>Repo: Result
    Repo-->>Caller: Completed ([SDN-BR-010](business-rules.md#sdn-br-010-collection-case-payments-are-applied-by-the-oracle-package-applypayments-for-the-case-and-payment-date))

Design constraints

  • Session, transaction, and connection-string management are entirely external to this library, provided by SAIF.Framework.Data.NHibernate and configured by the consuming application (saif-data-nhibernate-analysis.md Architecture findings)*.
  • Two database engines are in play: Oracle for almost all maps, plus one SQL Server stored procedure (bp_clm_segmntn_complexity_score) for ClaimScoreRepository, which requires consumers to configure a second, unseen session factory (saif-data-nhibernate-analysis.md Open questions item 2)**.
  • GroupImageRepository.GetFilteredImageGroups's deleted-image filter (ImageDeleteCode != null || canSeeDeleted) is logically inverted relative to the project's deletion convention, an authorization bypass for deleted group images (SC-SDN-01, High severity, saif-data-nhibernate-security-analysis.md).
  • The Edi maps bind to the personal Oracle schema OPS$JIMMIL, a least-privilege and portability concern (SC-SDN-04)*.
  • ClaimBillEntryRepository's legacy named queries (ClaimBillEntry_GetNextBillFromQueue, ClaimBillEntry_RestoreBillToQueue) are defined but unused; bill-queue processing now delegates to SAIF.Data's Guidewire-backed CCClaimApiService (SDN-BR-001).
  • CollectionsRepository.GetDebtorSsn and SearchCollections handle debtor SSNs (PII) with no access check at this layer; callers must restrict access themselves (SC-SDN-03)*.
  • PolicyOutputDocumentExtensions is duplicated across SAIF.Data and SAIF.Data.NHibernate with divergent members, risking ambiguity when both namespaces are imported (saif-data-nhibernate-analysis.md Open questions item 9).

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • Data/SAIF.Data.NHibernate/SAIF.Data.NHibernate.csproj
  • Data/SAIF.Data.NHibernate/Repositories/ClaimBillEntryRepository.cs
  • Data/SAIF.Data.NHibernate/Repositories/CollectionsRepository.cs
  • Data/SAIF.Data.NHibernate/Repositories/Claims/Information/ClaimScoreRepository.cs
  • Data/SAIF.Data.NHibernate/Repositories/Groups/GroupImageRepository.cs
  • Data/SAIF.Data.NHibernate/Mappings/Claims/Bills/ClaimBillEntry.hbm.xml
  • Data/SAIF.Data.NHibernate/Mappings/Claims/Information/ClaimsAnalytics.hbm.xml
  • Data/SAIF.Data.NHibernate/Mappings/Collections/Collections.hbm.xml
  • Data/SAIF.Data.NHibernate/Mappings/Edi/EdiElementMap.cs
  • DependencyMaps/SAIF.DependencyMaps.Web.OnlineSupport/DependencyMap.cs