SQL-058: Create Transaction via AddTransaction¶
This ORM statement performs a create operation on Transaction via AddTransaction, executed from Services/SAIF.Services/Collections/CashReceiptsService.cs (L207).
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-058 |
| Operation type | Create |
| Execution method | ORM (IRepository.Add) |
| Database | Oracle |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | Transaction |
| Criteria property | N/A — ORM |
| Lifecycle method | AddTransaction |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
:Id |
Input | long |
N/A | Identifier from LEGAL_COLL_TRAN_SEQ.NEXTVAL |
:UpdateNum |
Input | int |
N/A | Version column (Version()); NHibernate writes its initial value |
:TransactionDate |
Input | DateTime |
N/A | |
:ReferenceText |
Input | string |
N/A | |
:TransactionAmount |
Input | decimal |
N/A | |
:OutstandingAmount |
Input | decimal |
N/A | |
:IsInterestCharged |
Input | bool |
N/A | Bound as 'Y'/'N' (YesNoType) |
:IsSystemGenerated |
Input | bool |
N/A | Bound as 'Y'/'N' (YesNoType) |
:UpdateUser |
Input | string |
N/A | |
:UpdateDate |
Input | DateTime |
N/A | |
:Case |
Input | Case |
N/A | Identifier of the referenced Case entity (References(x => x.Case)) |
:TransactionCode |
Input | TransactionCode |
N/A | Identifier of the referenced TransactionCode entity (References(x => x.TransactionCode)) |
:ApprovedByUser |
Input | WriteOffApprovalUser |
N/A | Identifier of the referenced WriteOffApprovalUser entity (References(x => x.ApprovedByUser)) |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| LEGAL_COLLECTION_TRANSACTION | INSERT | LEGAL_COLL_TRAN_SEQ_NUM, UPDATE_NUM, TRANSACTION_DATE, REFERENCE_TEXT, TRANSACTION_AMT, OUTSTANDING_AMT, INTEREST_FLAG, SYSTEM_GENERATED_FLAG, UPDATE_USER, UPDATE_DATE, LEGAL_COLLECTION_SEQ_NUM, LEGAL_COLLECTION_TRAN_CODE, APPROVED_BY_USER (identifier from sequence LEGAL_COLL_TRAN_SEQ.NEXTVAL) |
LINQ statement¶
Source: Services/SAIF.Services/Collections/CashReceiptsService.cs:207.
// Services/SAIF.Services/Collections/CashReceiptsService.cs:207
UnitOfWork.GetRepository<DataModel.Transaction>().Add(transData);
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 LEGAL_COLL_TRAN_SEQ.NEXTVAL
FROM DUAL
INSERT INTO LEGAL_COLLECTION_TRANSACTION (
LEGAL_COLL_TRAN_SEQ_NUM,
UPDATE_NUM,
TRANSACTION_DATE,
REFERENCE_TEXT,
TRANSACTION_AMT,
OUTSTANDING_AMT,
INTEREST_FLAG,
SYSTEM_GENERATED_FLAG,
UPDATE_USER,
UPDATE_DATE,
LEGAL_COLLECTION_SEQ_NUM,
LEGAL_COLLECTION_TRAN_CODE,
APPROVED_BY_USER)
VALUES (
:Id,
:UpdateNum,
:TransactionDate,
:ReferenceText,
:TransactionAmount,
:OutstandingAmount,
:IsInterestCharged,
:IsSystemGenerated,
:UpdateUser,
:UpdateDate,
:Case,
:TransactionCode,
:ApprovedByUser)
Translation notes:
- :Id is the value fetched from sequence LEGAL_COLL_TRAN_SEQ (GeneratedBy.Native("LEGAL_COLL_TRAN_SEQ")) before the INSERT; NHibernate assigns it to Transaction.Id.
- UPDATE_NUM is the optimistic-concurrency version column (Version(x => x.UpdateNum)); NHibernate sets its initial value on INSERT.
- :IsInterestCharged, :IsSystemGenerated are bound as 'Y' / 'N' (YesNoType).
- Reference FK values are bound from the associated entity's identifier; the referenced tables are not read or joined by this statement: Case → LEGAL_COLLECTION_SEQ_NUM (entity table LEGAL_COLLECTION not accessed); TransactionCode → LEGAL_COLLECTION_TRAN_CODE (entity table LEGAL_COLLECTION_TRAN_CODE not accessed); ApprovedByUser → APPROVED_BY_USER (entity table WRITEOFF_APPROVAL_USER not accessed).
- transData.Case is loaded by a separate SingleOrDefault(x => x.Id == cashReceipt.CaseId) query (CashReceiptsService.cs:199-201) and then modified (lines 203-206). At commit the stateful session flushes that dirty Case as an UPDATE of LEGAL_COLLECTION; that UPDATE is a separate statement and LEGAL_COLLECTION is not accessed by this INSERT.
Operations and processes¶
- CashReceiptsService.AddTransaction — see Operations and processes
Note: Statements marked with
**could not be confirmed; treat as unknown until verified.
Sources¶
Services/SAIF.Services/Collections/CashReceiptsService.cs (L207)