Skip to content

SQL-245: Retrieve OutputLog via ReplaceImageIdsInOutputLog

This ORM statement retrieves OutputLog rows for a given output document and image, so their image id can be replaced in memory, via IUnitOfWork.GetRepository<T>(), executed from Services/SAIF.Services/OutputDocuments/PolicyDocumentsService.cs (L476-479).

Classification

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

Parameters

Parameter Direction Type Max length Description
:Id Input long N/A replace.Id, matched against output_document_seq_num
:ImageId Input long N/A existingDoc.OutputDocument.ImageId, matched against image_seq_num

Tables

Table Access Columns used
OUTPUT_LOG SELECT output_log_seq_num, image_seq_num, output_document_seq_num, policy_num, doc_type_code

LINQ statement

Source: Services/SAIF.Services/OutputDocuments/PolicyDocumentsService.cs:476

// Services/SAIF.Services/OutputDocuments/PolicyDocumentsService.cs:476-479
unitOfWork.GetRepository<OutputLog>().Query()
    .Where(x => x.OutputDocumentId == replace.Id && x.ImageId == existingDoc.OutputDocument.ImageId)
    .ToArray()
    .Each(x => x.ImageId = replace.ReplacementImageId);

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
  OL.output_log_seq_num,
  OL.image_seq_num,
  OL.output_document_seq_num,
  OL.policy_num,
  OL.doc_type_code
FROM output_log OL
WHERE OL.output_document_seq_num = :Id
  AND OL.image_seq_num = :ImageId

Translation notes: - .ToArray() is the materialization point; .Each(x => x.ImageId = replace.ReplacementImageId) runs in memory. Under a stateful session the modified entities are flushed as UPDATE output_log statements at commit; that write is not part of this Read statement. - existingDoc.OutputDocument.ImageId is a member of an already-loaded captured object and is bound as a value — it does not navigate from the queried entity, so output_document is not joined.

Operations and processes

Sources

  • Services/SAIF.Services/OutputDocuments/PolicyDocumentsService.cs (L476)