---
title: "SQL-014: Create CertificatePreference via AddPreference"
summary: Create operation against CertificatePreference via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-014: Create CertificatePreference via AddPreference

This ORM statement performs a create operation on `CertificatePreference` via `AddPreference`, executed from `Services/SAIF.Services/Policies/Certificates/CertificatePreferenceService.cs` (L88).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-014 |
| **Operation type** | Create |
| **Execution method** | ORM (IRepository.Add) |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `CertificatePreference` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `AddPreference` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:PolicyNumber` | Input | `long` | N/A | Identifier supplied by the caller |
| `:DeliveryMethod` | Input | `DeliveryMethods` | N/A | Custom type `CertificateDeliveryMethodsType` |
| `:RenewalNotificationType` | Input | `RenewalNotificationTypes` | N/A | Custom type `CertificateRenewalNotificationTypesType` |
| `:EmailAddress` | Input | `string` | N/A |  |
| `:FaxNumber` | Input | `string` | N/A |  |
| `:UpdateUser` | Input | `string` | N/A |  |
| `:UpdateDate` | Input | `DateTime` | N/A |  |
| `:CreateUser` | Input | `string` | N/A |  |
| `:CreateDate` | Input | `DateTime` | N/A |  |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CERTIFICATE_PREFERENCE](../database-tables.md#certificate_preference) | INSERT | POLICY_NUMBER, DELIVERY_METHOD_CODE, RENEWAL_NOTIFICATION_CODE, EMAIL_ADDRESS, FAX_NUMBER, UPDATE_USER, UPDATE_DATE, CREATE_USER, CREATE_DATE |

## LINQ statement

Source: `Services/SAIF.Services/Policies/Certificates/CertificatePreferenceService.cs:88`.

```csharp
// Services/SAIF.Services/Policies/Certificates/CertificatePreferenceService.cs:88
unitOfWork.GetRepository<CertData.CertificatePreference>().Add(certificatePreferenceData);
```

## 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
INSERT INTO CERTIFICATE_PREFERENCE (
  POLICY_NUMBER,
  DELIVERY_METHOD_CODE,
  RENEWAL_NOTIFICATION_CODE,
  EMAIL_ADDRESS,
  FAX_NUMBER,
  UPDATE_USER,
  UPDATE_DATE,
  CREATE_USER,
  CREATE_DATE)
VALUES (
  :PolicyNumber,
  :DeliveryMethod,
  :RenewalNotificationType,
  :EmailAddress,
  :FaxNumber,
  :UpdateUser,
  :UpdateDate,
  :CreateUser,
  :CreateDate)
```

Translation notes:
- `GeneratedBy.Assigned()`: `:PolicyNumber` is supplied by the caller. Because the identifier is assigned, a stateful `SaveOrUpdate` cannot tell a new instance from a detached one by identifier alone; NHibernate may first issue a `SELECT` by `POLICY_NUMBER` (or rely on the version unsaved-value, if mapped) to decide between INSERT and UPDATE.

## Operations and processes
- CertificatePreferenceService.AddPreference — see [Operations and processes](../operations-processes.md)

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `Services/SAIF.Services/Policies/Certificates/CertificatePreferenceService.cs (L88)`
