Skip to content

SQL-264: Retrieve Policy

This statement reads a single POLICY row by policy number, used by PolicyInformationService to resolve the policy name and to determine whether the policy's entity code is the state-entity code. It is issued via NHibernate LINQ from Services/SAIF.Services/Policies/Information/PolicyInformationService.cs, at two call sites (GetPolicyName and IsPolicyStateEntity) that only run when policyNumber >= 18.

Classification

Field Value
SQL ID SQL-264
Operation type Read
Execution method ORM (NHibernate LINQ)
Database Oracle
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object PolicyInformationService
Criteria property N/A — ORM
Lifecycle method GetPolicyName, IsPolicyStateEntity

Parameters

Parameter Direction Type Max length Description
:policyNumber Input long N/A Policy number to look up (x.PolicyNumber == policyNumber)

Tables

Table Access Columns used
POLICY SELECT POLICY_NUM, POLICY_NAME, LEGAL_NAME, SECURE_POLICY_CODE, OFFICE_CODE, ACCOUNT_NUM, POLICY_STATUS_CODE, MARKET_TYPE_CODE, POLICY_RELATIONSHIP_POLICY_NUM, POLICY_RELATIONSHIP_CODE, customer_service_team_code, ENTITY_CODE, TRADING_SEQ_NUM, RATE_ACCOUNT, AGENT_NUM

LINQ statement

Source: Services/SAIF.Services/Policies/Information/PolicyInformationService.cs:33

// Services/SAIF.Services/Policies/Information/PolicyInformationService.cs:33-34
var policy = _unitOfWork.GetRepository<PolicyData.Policy>().Query()
    .SingleOrDefault(x => x.PolicyNumber == policyNumber);

// Services/SAIF.Services/Policies/Information/PolicyInformationService.cs:45-46
var policy = _unitOfWork.GetRepository<PolicyData.Policy>().Query()
    .SingleOrDefault(x => x.PolicyNumber == policyNumber);

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.

-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT
  P.POLICY_NUM,
  P.POLICY_NAME,
  P.LEGAL_NAME,
  P.SECURE_POLICY_CODE,
  P.OFFICE_CODE,
  P.ACCOUNT_NUM,
  P.POLICY_STATUS_CODE,
  P.MARKET_TYPE_CODE,
  P.POLICY_RELATIONSHIP_POLICY_NUM,
  P.POLICY_RELATIONSHIP_CODE,
  P.customer_service_team_code,
  P.ENTITY_CODE,
  P.TRADING_SEQ_NUM,
  P.RATE_ACCOUNT,
  P.AGENT_NUM
FROM POLICY P
WHERE P.POLICY_NUM = :policyNumber
-- NHibernate expects at most one row

Translation notes: - Both call sites run only when policyNumber >= 18 (C# guard, not a SQL predicate). - PolicyEntity.StateEntity = "50" (Data/SAIF.Data/Model/Policies/PolicyEntity.cs:5) is compared in memory. - Single/SingleOrDefault → no row limit; NHibernate throws if more than one row is returned. - OFFICE_CODE is mapped both as Map(OfficeCode) (PolicyMap.cs:18) and References(Office) (PolicyMap.cs:26); it is selected once. All other References contribute their FK column only; HasMany collections (Periods, DbaNames, OscPolicies, SubmissionPolicies, TeamFunctions, BusinessAffiliates) are lazy and not selected.

Operations and processes

Sources

  • Services/SAIF.Services/Policies/Information/PolicyInformationService.cs (L33, L45)