Skip to content

SQL-374: Delete DocumentTemplate via DeleteTemplate

This statement deletes the DocumentTemplate entity identified by its identifier (DOCUMENT_TEMPLATE_SEQ_NUM) via IUnitOfWork.GetRepository<T>().Delete(entity), invoked from TemplateSearchService.DeleteTemplate (Services/SAIF.Services/Documents/TemplateSearchService.cs:907). The template's child output profiles and options are deleted by the caller before this statement runs. The SQL below is inferred from this repository call and the DocumentTemplate NHibernate mapping — it is not literal SQL present in source.

Classification

Field Value
SQL ID SQL-374
Operation type Delete
Execution method ORM (IRepository.Delete)
Database Oracle
Schema [unqualified]**
Command type N/A (ORM-generated)
Business object DocumentTemplate
Criteria property N/A — ORM
Lifecycle method DeleteTemplate

Parameters

Parameter Direction Type Max length Description
:Id Input long N/A Identifier of the DocumentTemplate being deleted (DOCUMENT_TEMPLATE_SEQ_NUM)

Tables

Table Access Columns used
DOCUMENT_TEMPLATE DELETE DOCUMENT_TEMPLATE_SEQ_NUM

LINQ statement

Source: Services/SAIF.Services/Documents/TemplateSearchService.cs:907

// Services/SAIF.Services/Documents/TemplateSearchService.cs:907
unitOfWork.GetRepository<DocumentTemplate>().Delete(currentTemplate);

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
DELETE FROM DOCUMENT_TEMPLATE
WHERE DOCUMENT_TEMPLATE_SEQ_NUM = :Id

Translation notes:

  • HasMany(DocumentTemplateOutputProfiles) and HasMany(DocumentTemplateOptions) are .Inverse() with no cascade (lines 15-21), so deleting the template does not cascade; the caller deletes children first (TemplateSearchService.cs:902-904).
  • Entity loaded at line 895 (TemplateQuery.SingleOrDefault), a separate read.

Operations and processes

Sources

  • Services/SAIF.Services/Documents/TemplateSearchService.cs (L907)