---
title: "SQL-241: Retrieve OutputDocument"
summary: Read operation against OutputDocument via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-241: Retrieve OutputDocument

This ORM statement retrieves a single `OutputDocument` by its primary key, via `IUnitOfWork.GetRepository<T>()`, executed from `Services/SAIF.Services/OutputDocuments/PolicyDocumentsBatchService.cs (L115, L351)`. `ReleaseDocuments` looks up the document with a LINQ `Single`, and `FillOutputDocumentProperty` reloads it with `IRepository.Get`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-241 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) (L115); ORM (IRepository.Get) (L351) |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `PolicyDocumentsBatchService` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `ReleaseDocuments`, `FillOutputDocumentProperty` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | long | N/A | `x.Id` (L115) — id of the document being released |
| `:id` | Input | long | N/A | `releasedAgencyDeliveredSaifDoc.Id` (L351) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [OUTPUT_DOCUMENT](../database-tables.md#output_document) | SELECT | `output_document_seq_num`, `update_num`, `image_seq_num`, `document_create_date`, `description`, `create_user`, `create_date`, `update_user`, `update_date`, `output_document_type_code` |

## LINQ statement

Source: `Services/SAIF.Services/OutputDocuments/PolicyDocumentsBatchService.cs:115`

```csharp
// Services/SAIF.Services/OutputDocuments/PolicyDocumentsBatchService.cs:115
var outputDocument = unitOfWork.GetRepository<OutputDocument>().Query().Single(od => od.Id == x.Id);

// Services/SAIF.Services/OutputDocuments/PolicyDocumentsBatchService.cs:350-351
releasedAgencyDeliveredSaifDoc.OutputDocument =
    unitOfWork.GetRepository<OutputDocument>().Get(releasedAgencyDeliveredSaifDoc.Id);
```

## Sample SQL

> **Inferred SQL:** This SQL was inferred from the LINQ statement above and the NHibernate mappings. It is not concrete SQL from source code; NHibernate generates the executed statement at runtime, so aliases, column order, join syntax, and bind-parameter names may differ.

```sql
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
-- ReleaseDocuments (L115): single-row lookup of OutputDocument by primary key (Single)
SELECT
  OD.output_document_seq_num,
  OD.update_num,
  OD.image_seq_num,
  OD.document_create_date,
  OD.description,
  OD.create_user,
  OD.create_date,
  OD.update_user,
  OD.update_date,
  OD.output_document_type_code
FROM output_document OD
WHERE OD.output_document_seq_num = :Id
-- NHibernate expects at most one row

-- FillOutputDocumentProperty (L351): Get(releasedAgencyDeliveredSaifDoc.Id)
SELECT
  OD.output_document_seq_num,
  OD.update_num,
  OD.image_seq_num,
  OD.document_create_date,
  OD.description,
  OD.create_user,
  OD.create_date,
  OD.update_user,
  OD.update_date,
  OD.output_document_type_code
FROM output_document OD
WHERE OD.output_document_seq_num = :id
```

Translation notes:
- `Get(id)` may be satisfied from the session first-level cache without a round trip.
- `HasOne(PolicyOutputDocument).Cascade.All()` is a one-to-one association; it is not part of the selected column list.

## Operations and processes
- PolicyDocumentsBatchService.FillOutputDocumentProperty — see [Operations and processes](../operations-processes.md)
- PolicyDocumentsBatchService.ReleaseDocuments — see [Operations and processes](../operations-processes.md)

## Business rules
- [SVC-BR-POL-091 Release pending documents with DocumentDate ≤ document system date](../business-rules.md#svc-br-pol-091-release-pending-documents-with-documentdate-%E2%89%A4-document-system-date)
- [SVC-BR-POL-092 Direct-writer notifications only if SAIF agency IsPaperlessForPolicyHolderCopyOfDocuments](../business-rules.md#svc-br-pol-092-direct-writer-notifications-only-if-saif-agency-ispaperlessforpolicyholdercopyofdocuments)

## Sources
- `Services/SAIF.Services/OutputDocuments/PolicyDocumentsBatchService.cs (L115, L351)`
