Skip to content

SQL-198: PolicyQueryProvider.GetGroupAssociation

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by PolicyQueryProvider.GetGroupAssociation.

Classification

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

Parameters

Parameter Direction Type Max length Description
policyNumber Input long N/A Method argument of PolicyQueryProvider.GetGroupAssociation bound into the ORM expression; NHibernate generates the bind variable at runtime
effectiveDate Input DateTime N/A Method argument of PolicyQueryProvider.GetGroupAssociation bound into the ORM expression; NHibernate generates the bind variable at runtime

Tables

Table Access Columns used
POLICY_PERIOD_GROUP_ASSOC SELECT policy_num, policy_period_eff_date, GROUP_ASSOCIATION_CODE, CHAPTER_CODE, GROUP_MBRSHP_EFF_DATE, GROUP_MBRSHP_EXP_DATE, GROUP_TERMINATION_DATE, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE

LINQ statement

Source: Data/SAIF.Data/Queries/Policies/PolicyQueryProvider.cs:50-52.

public PolicyPeriodGroupAssoc GetGroupAssociation(long policyNumber, DateTime effectiveDate)
{
    return Factory.GetRepository<PolicyPeriodGroupAssoc>().Query()
        .FirstOrDefault(x => x.Policy.PolicyNumber == policyNumber 
        && x.Period.EffectiveDate == effectiveDate);
}

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 * FROM (
  SELECT
    PPGA.policy_num,
    PPGA.policy_period_eff_date,
    PPGA.GROUP_ASSOCIATION_CODE,
    PPGA.CHAPTER_CODE,
    PPGA.GROUP_MBRSHP_EFF_DATE,
    PPGA.GROUP_MBRSHP_EXP_DATE,
    PPGA.GROUP_TERMINATION_DATE,
    PPGA.CREATE_USER,
    PPGA.CREATE_DATE,
    PPGA.UPDATE_USER,
    PPGA.UPDATE_DATE
  FROM POLICY_PERIOD_GROUP_ASSOC PPGA
  WHERE PPGA.policy_num = :policyNumber
    AND PPGA.policy_period_eff_date = :effectiveDate
) WHERE ROWNUM <= 1

Translation notes: - Translation decision: PolicyPeriodMap maps EffectiveDate both as a composite-key property (line 16) and as a plain Map (line 19) on the same column. NHibernate resolves Period.EffectiveDate against the component identifier, so no join to Policy_Period is needed. If a given NHibernate version resolved the path through the plain property instead, it would add INNER JOIN Policy_Period on the two key columns. That join would still return the same rows. - policy_num is shared by the composite key, References(Policy), and References(Period). It is selected once.

Operations and processes

Sources

  • Data/SAIF.Data/Queries/Policies/PolicyQueryProvider.cs:50