SQL-222: ReserveQueryProvider.GetLatestIncurredCost¶
This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by ReserveQueryProvider.GetLatestIncurredCost.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-222 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle* |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | ReserveQueryProvider |
| Criteria property | N/A — ORM |
| Lifecycle method | GetLatestIncurredCost |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
claimId |
Input | long | N/A | Method argument of ReserveQueryProvider.GetLatestIncurredCost bound into the ORM expression; NHibernate generates the bind variable at runtime |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| CL_INCURRED_COST_HISTORY | SELECT (outer + subquery) | CL_INCURRED_COST_HIST_SEQ_NUM, UPDATE_NUM, CLAIM_COST_DATE, RESERVE_APPROVER_USER, RESERVE_INITIATOR_USER, GENERAL_ANALYSIS_TEXT, UPDATE_DATE, UPDATE_USER, CLAIM_ID |
LINQ statement¶
Source: Data/SAIF.Data/Queries/Claims/ReserveQueryProvider.cs:23-26. The repository/queryable is initialised at Data/SAIF.Data/Queries/Claims/ReserveQueryProvider.cs:17.
// Data/SAIF.Data/Queries/Claims/ReserveQueryProvider.cs:17
repository = Factory.GetRepository<IncurredCostHistory>().Query();
// Data/SAIF.Data/Queries/Claims/ReserveQueryProvider.cs:23-26
public IncurredCostHistory GetLatestIncurredCost(long claimId)
{
return repository.Where(w => w.Claim.Id == claimId)
.SingleOrDefault(x => x.Id == repository
.Where(w => w.Claim.Id == claimId)
.Max(m => m.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
CICH.CL_INCURRED_COST_HIST_SEQ_NUM,
CICH.UPDATE_NUM,
CICH.CLAIM_COST_DATE,
CICH.RESERVE_APPROVER_USER,
CICH.RESERVE_INITIATOR_USER,
CICH.GENERAL_ANALYSIS_TEXT,
CICH.UPDATE_DATE,
CICH.UPDATE_USER,
CICH.CLAIM_ID
FROM CL_INCURRED_COST_HISTORY CICH
WHERE CICH.CLAIM_ID = :claimId
AND CICH.CL_INCURRED_COST_HIST_SEQ_NUM = (
SELECT MAX(CICH2.CL_INCURRED_COST_HIST_SEQ_NUM)
FROM CL_INCURRED_COST_HISTORY CICH2
WHERE CICH2.CLAIM_ID = :claimId
)
-- SingleOrDefault: NHibernate expects at most one row
Translation notes:
- The inner repository.Where(w => w.Claim.Id == claimId).Max(m => m.Id) sits inside the outer lambda, so NHibernate emits it as a scalar subquery in one round trip.
Operations and processes¶
Sources¶
Data/SAIF.Data/Queries/Claims/ReserveQueryProvider.cs:23