Skip to content

SQL-305: Retrieve Subpoena

This statement retrieves a single subpoena by its identifier from SUBPOENA via NHibernate LINQ over IUnitOfWork.GetRepository<Subpoena>(). It is called from five sites in SubpoenaDocumentService (Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs (L96, L123, L167, L191, L265)) to load the subpoena that document-generation and process-server-email operations act on.

Classification

Field Value
SQL ID SQL-305
Operation type Read
Execution method ORM (NHibernate LINQ)
Database Oracle
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object SubpoenaDocumentService
Criteria property N/A — ORM
Lifecycle method GetPreviewSubpoena, PrintSubpoena, AddSubpoenaDocumentToList, GenerateCashDisbursement, GetProcessServerEmailSubpoena

Parameters

Parameter Direction Type Max length Description
:id Input Long N/A Subpoena identifier (id) matched against SUBPOENA_SEQ_NUM

Tables

Table Access Columns used
SUBPOENA SELECT SUBPOENA_SEQ_NUM, UPDATE_NUM, SUBPOENA_TEXT, SUBPOENA_OPENING_TEXT, SHOW_APPEARANCE_FLAG, ISSUE_DATE, REQUESTED_BY_EMPLID, APPROVED_DATE, APPROVED_BY_EMPLID, APPEARANCE_DATE_TIME, COMPLIANCE_DATE, BODY_PART_DESC, RECORDS_REQUEST_FROM_DATE, RECORDS_REQUEST_THRU_DATE, PAGE_COUNT, SAIF_LOCATION_FLAG, ADDITIONAL_CLAIM_NUMBERS, ADDITIONAL_CASE_NUMBERS, AKA_NAME, SERVE_BY_DATE, SPECIFIC_LOCATION_TEXT, SPECIAL_DELIVERY_TEXT, FILE_NUMBER, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE, LEGAL_CASE_SEQ_NUM, SUBPOENA_STATUS_CODE, SUBPOENA_TYPE_CODE, HEARING_LOCATION_SEQ_NUM, SPECIAL_HANDLING_CODE, PROCESS_SERVER_LOC_SEQ_NUM

LINQ statement

Source: Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:96

// Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:96-98
var subpoena = _unitOfWork.GetRepository<SubpoenaData.Subpoena>()
    .Query()
    .FirstOrDefault(x => x.Id == id);

// Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:123-125
var subpoena = _unitOfWork.GetRepository<SubpoenaData.Subpoena>()
    .Query()
    .FirstOrDefault(x => x.Id == id);

// Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:167-169
var subpoena = _unitOfWork.GetRepository<SubpoenaData.Subpoena>()
    .Query()
    .FirstOrDefault(x => x.Id == id);

// Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:191-193
var subpoena = _unitOfWork.GetRepository<SubpoenaData.Subpoena>()
    .Query()
    .FirstOrDefault(x => x.Id == id);

// Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs:265-267
var subpoena = _unitOfWork.GetRepository<SubpoenaData.Subpoena>()
    .Query()
    .FirstOrDefault(x => x.Id == 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.

-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT *
FROM (
  SELECT
    S.SUBPOENA_SEQ_NUM,
    S.UPDATE_NUM,
    S.SUBPOENA_TEXT,
    S.SUBPOENA_OPENING_TEXT,
    S.SHOW_APPEARANCE_FLAG,
    S.ISSUE_DATE,
    S.REQUESTED_BY_EMPLID,
    S.APPROVED_DATE,
    S.APPROVED_BY_EMPLID,
    S.APPEARANCE_DATE_TIME,
    S.COMPLIANCE_DATE,
    S.BODY_PART_DESC,
    S.RECORDS_REQUEST_FROM_DATE,
    S.RECORDS_REQUEST_THRU_DATE,
    S.PAGE_COUNT,
    S.SAIF_LOCATION_FLAG,
    S.ADDITIONAL_CLAIM_NUMBERS,
    S.ADDITIONAL_CASE_NUMBERS,
    S.AKA_NAME,
    S.SERVE_BY_DATE,
    S.SPECIFIC_LOCATION_TEXT,
    S.SPECIAL_DELIVERY_TEXT,
    S.FILE_NUMBER,
    S.CREATE_USER,
    S.CREATE_DATE,
    S.UPDATE_USER,
    S.UPDATE_DATE,
    S.LEGAL_CASE_SEQ_NUM,
    S.SUBPOENA_STATUS_CODE,
    S.SUBPOENA_TYPE_CODE,
    S.HEARING_LOCATION_SEQ_NUM,
    S.SPECIAL_HANDLING_CODE,
    S.PROCESS_SERVER_LOC_SEQ_NUM
  FROM SUBPOENA S
  WHERE S.SUBPOENA_SEQ_NUM = :id
)
WHERE ROWNUM <= 1

Translation notes: - Five call sites, identical shape. - First/FirstOrDefault → Oracle10 dialect row limit SELECT * FROM (...) WHERE ROWNUM <= 1. - References (LegalCase, SubpoenaStatus, SubpoenaType, HearingLocation, SpecialHandling, ProcessServerLocation) contribute FK columns only; HasMany(Recipients) is lazy — subpoena.Recipients.Any() after materialization triggers a separate lazy collection load that is not part of this statement.

Operations and processes

Sources

  • Services/SAIF.Services/Legal/Subpoenas/SubpoenaDocumentService.cs (L96, L123, L167, L191, L265)