# Business Logic — JBSbatKKAdHenkoHoyuDataUpdOtr.executeZM_M_AD_KK_SELECT_012() [9 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKAdHenkoHoyuDataUpdOtr` |
| Layer | Service (Batch / CBS Common Component) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKAdHenkoHoyuDataUpdOtr.executeZM_M_AD_KK_SELECT_012()

This method performs a **single-row address master lookup** by address code, serving as the data retrieval primitive for the batch processing pipeline. Its business purpose is to fetch historical (pre-modification) address records from the `ZM_M_AD` address master table whenever a referenced address code is not already present in the pre-loaded in-memory cache (`adBfList`). The method implements the **repository/data-accessor pattern** — it encapsulates all database interaction details (parameter binding, SQL execution) behind a simple interface that accepts an address code and populates the shared `db_ZM_M_AD` accessor with the query result for downstream consumption. This method is the sole data-fetching mechanism for address master lookups within the `JBSbatKKAdHenkoHoyuDataUpdOtr` batch job, which handles address-related modification data updatable processing. The SQL key `KK_SELECT_012` defines the specific SELECT statement against the address master table `ZM_M_AD`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeZM_M_AD_KK_SELECT_012 param"])
    STEP1(["Generate bound variable list<br>JBSbatCommonDBInterface paramList"])
    STEP2(["Set address code into paramList<br>setValue param[0].toString()"])
    STEP3(["Execute DB SELECT<br>db_ZM_M_AD.selectBySqlDefine<br>paramList KK_SELECT_012"])
    END_NODE(["Return void<br>Next processing step"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> END_NODE
```

**Processing Summary:**
The method follows a linear, unconditional three-step flow:
1. **Bind variable initialization** — Creates a `JBSbatCommonDBInterface` instance to hold the bound variable(s) for the SQL query.
2. **Parameter binding** — Extracts the address code from the input `param[0]` array (converted via `toString()`), and binds it as the WHERE clause parameter via `setValue()`.
3. **SQL execution** — Invokes `selectBySqlDefine()` on the `db_ZM_M_AD` SQL access component with the bound parameters and the SQL key `KK_SELECT_012`. The result is stored in the shared accessor for retrieval by `selectNext()` in the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `Object[]` | Array of bind variables for the address code lookup. `param[0]` is the **address code** (住所コード) — the unique identifier used to retrieve a specific address record from the address master table (`ZM_M_AD`). The address code serves as the primary key or unique lookup criterion for finding historical address data during batch modification processing. |

**Caller-provided state:**

| No | Field / External State | Type | Business Description |
|----|----------------------|------|---------------------|
| 1 | `db_ZM_M_AD` | `JBSbatSQLAccess` | SQL access component for the `ZM_M_AD` address master table. Holds the query result set after `selectBySqlDefine()` executes. The caller reads results from this component via `db_ZM_M_AD.selectNext()` after this method returns. |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatCommonDBInterface.setValue` | JDKStructuredMap | - | Binds the address code value into the paramList (bound variable holder) |
| R | `db_ZM_M_AD.selectBySqlDefine` | db_ZM_M_AD | ZM_M_AD | Executes the `KK_SELECT_012` SQL SELECT statement against the address master table using the bound address code as the WHERE clause parameter. Returns the matching address record for downstream processing. |

**CRUD Classification Rationale:**
- `setValue` — **R** (Read): Populates the parameter binding list; this is a data preparation operation feeding the read query.
- `selectBySqlDefine` — **R** (Read): Executes a SQL SELECT statement to retrieve a single address record from `ZM_M_AD` by address code. No modifications to data.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `setValue` [-], `selectBySqlDefine` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:JBSbatKKAdHenkoHoyuDataUpdOtr | `execute()` -> `executeZM_M_AD_KK_SELECT_012(adCd)` | `selectBySqlDefine [R] ZM_M_AD` |

**Call chain detail:**
- The batch job's `execute()` method iterates over address data to be processed. For each address code not found in the pre-loaded `adBfList` cache, it calls `executeZM_M_AD_KK_SELECT_012(new String[]{adCd})` to fetch the historical address record from the database, then retrieves it via `db_ZM_M_AD.selectNext()`.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(bound variable initialization)` (L367)

> Initializes the bound variable list for the SQL SELECT query. Creates a new `JBSbatCommonDBInterface` instance to serve as the parameter container.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface paramList = new JBSbatCommonDBInterface()` // Generate bound variable list (バイン変数のリストを生成します) |

**Block 2** — [EXEC] `(address code parameter binding)` (L368)

> Binds the address code (住所コード) from the input parameter array into the bound variable list. The address code is extracted from `param[0]` and converted to a String via `toString()`, then set as the first bind variable.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramList.setValue(param[0].toString())` // Set address code into paramList (バイン変数の値をparam配列に入れます) |

**Block 3** — [CALL] `(DB SELECT execution)` (L371)

> Executes the SQL SELECT query defined by the key `KK_SELECT_012` against the address master table. The bound parameters (`paramList`) contain the address code for the WHERE clause filter. The `ZM_M_AD_KK_SELECT_012` constant resolves to `"KK_SELECT_012"` [-> `ZM_M_AD_KK_SELECT_012="KK_SELECT_012"` (JBSbatKKAdHenkoHoyuDataUpdOtr.java:57)]. The query result is stored in the `db_ZM_M_AD` SQL access component for the caller to retrieve via `selectNext()`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_ZM_M_AD.selectBySqlDefine(paramList, ZM_M_AD_KK_SELECT_012)` // Execute DB access (DBアクセスを実行します) [-> `ZM_M_AD_KK_SELECT_012="KK_SELECT_012"` (JBSbatKKAdHenkoHoyuDataUpdOtr.java:57)] |

**Block 4** — [RETURN] `(void return)` (L373)

> Returns void to the caller. The caller (`execute()` method) then retrieves the query result via `db_ZM_M_AD.selectNext()` which returns the fetched address map.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `(void)` // Method returns; caller uses db_ZM_M_AD.selectNext() to read result |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `adCd` | Field | Address Code (住所コード) — Unique identifier for an address record in the address master table `ZM_M_AD`. Used as the primary lookup key for retrieving historical address data. |
| `ZM_M_AD` | Entity | Address Master Table — The database entity containing address master data. This is a reference/master table that stores address definitions used throughout the batch processing pipeline. |
| `KK_SELECT_012` | SQL Key | SQL define key — The identifier for the specific SELECT statement used to look up an address record from `ZM_M_AD` by address code. Defined in the SQL definition XML configuration. |
| `paramList` | Variable | Bound Variable List — A `JBSbatCommonDBInterface` container holding SQL bind variables. Maps Java values to SQL placeholder parameters for prepared statement execution. |
| `db_ZM_M_AD` | Component | SQL Access Component for ZM_M_AD — A `JBSbatSQLAccess` instance configured for database operations on the `ZM_M_AD` address master table. Manages query execution, result set iteration, and connection lifecycle. |
| `JBSbatCommonDBInterface` | Class | Common Database Interface — A parameter container class that holds bind variable values for SQL execution. Provides `setValue()` for binding parameters and acts as the parameter transfer object for SQL access methods. |
| `selectBySqlDefine` | Method | SQL Define-based SELECT — Executes a SELECT statement identified by a SQL key string (e.g., "KK_SELECT_012") using the provided bind variables. The SQL definition is resolved from external XML configuration. |
| `adBfList` | Field | Pre-modification Address List (変更前住所リスト) — A HashMap caching address records loaded before the main processing loop. Avoids redundant DB lookups for addresses that appear multiple times. |
| `selectNext` | Method | Get Next Result Row — Retrieves the next row from the result set populated by the last `selectBySqlDefine()` call. Returns a `HashMap` representing the address record. |
| `JBSbatSQLAccess` | Class | Batch SQL Access Framework — Enterprise framework class for executing SQL statements in batch processing. Provides `selectBySqlDefine()`, `selectNext()`, `close()`, and other database interaction methods. |
| `execute()` | Method | Batch Entry Point — The main entry point of the `JBSbatKKAdHenkoHoyuDataUpdOtr` batch job that orchestrates the full address modification data processing flow, including pre-loading address caches and iterating through records. |
