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

# SQL-203: Retrieve HostileWorkerCode via CreateOverride

This statement looks up a hostile-worker code by its code value so that `SecurityOverrideService.CreateOverride` can populate the `HostileWorker` reference on a new security override. It is issued through NHibernate LINQ against the `HostileWorkerCode` entity from `Services/SAIF.Services/Claims/SecurityOverride/SecurityOverrideService.cs:112`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-203 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `SecurityOverrideService` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `CreateOverride` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:hostileWorkerCode` | Input | string | N/A | `claimData.Worker.HostileWorker.Code`, captured |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CL_HOSTILE_WORKER_CODE](../database-tables.md#cl_hostile_worker_code) | SELECT | CODE, CODE_DESCR, UPDATE_DATE, UPDATE_NUM, UPDATE_USER |

## LINQ statement

Source: `Services/SAIF.Services/Claims/SecurityOverride/SecurityOverrideService.cs:112`

```csharp
HostileWorker = unitOfWork.GetRepository<Data.Model.Claims.CodeTables.HostileWorkerCode>()
        .Query()
        .SingleOrDefault(x => x.Code == claimData.Worker.HostileWorker.Code),
```

## 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
SELECT HW.CODE,
       HW.CODE_DESCR,
       HW.UPDATE_DATE,
       HW.UPDATE_NUM,
       HW.UPDATE_USER
FROM   CL_HOSTILE_WORKER_CODE HW
WHERE  HW.CODE = :hostileWorkerCode;
-- NHibernate expects at most one row
```

Translation notes:
- `SingleOrDefault`/`Single` add no row limit; NHibernate throws if more than one row is returned.
- Fragment is an object-initializer member (`HostileWorker = ...`) inside the `new SecurityOverride { ... }` begun at L104.

## Operations and processes
- SecurityOverrideService.CreateOverride — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Claims/SecurityOverride/SecurityOverrideService.cs (L112)`
