33Bold provides transparent ** Object-Relational Mapping (ORM)** that automatically persists your domain objects to a relational database.
44
55## Architecture
6-
76``` mermaid
87flowchart LR
98 subgraph ObjectSpace["Object Space"]
@@ -37,44 +36,76 @@ flowchart LR
3736| Inheritance | Type discriminator column |
3837
3938### Example Mapping
39+ ``` mermaid
40+ flowchart LR
41+ subgraph UML["UML Model"]
42+ Customer["Customer\n───────────\nName: String\nEmail: String"]
43+ Order["Order\n───────────\nOrderDate: Date\nTotal: Currency"]
44+ OrderItem["OrderItem\n───────────\nQuantity: Integer"]
45+ end
4046
47+ subgraph DB["Database Schema"]
48+ T1["CUSTOMER"]
49+ T2["CUSTOMER_ORDER"]
50+ T3["ORDER_ITEM"]
51+ end
52+
53+ Customer --> T1
54+ Order --> T2
55+ OrderItem --> T3
4156```
42- UML Model Database Schema
43- ─────────── ───────────────
44- ┌─────────────┐ ┌─────────────────────────┐
45- │ Customer │ │ CUSTOMER │
46- ├─────────────┤ ├─────────────────────────┤
47- │ Name: String│ ────────► │ BOLD_ID INT PK │
48- │ Email:String│ │ BOLD_TYPE INT │
49- └─────────────┘ │ NAME VARCHAR │
50- │ EMAIL VARCHAR │
51- └─────────────────────────┘
57+ ``` mermaid
58+ erDiagram
59+ CUSTOMER {
60+ INT BOLD_ID PK
61+ INT BOLD_TYPE
62+ VARCHAR NAME
63+ VARCHAR EMAIL
64+ }
65+
66+ CUSTOMER_ORDER {
67+ INT BOLD_ID PK
68+ INT BOLD_TYPE
69+ INT CUSTOMER_ID FK
70+ DATE ORDERDATE
71+ DECIMAL TOTAL
72+ }
73+
74+ ORDER_ITEM {
75+ INT BOLD_ID PK
76+ INT BOLD_TYPE
77+ INT ORDER_ID FK
78+ INT PRODUCT_ID FK
79+ INT QUANTITY
80+ }
81+
82+ CUSTOMER ||--o{ CUSTOMER_ORDER : "places"
83+ CUSTOMER_ORDER ||--o{ ORDER_ITEM : "contains"
5284```
5385
5486## Configuration
5587
5688### Database Adapter Setup
57-
5889``` pascal
5990// FireDAC adapter (recommended)
6091BoldDatabaseAdapterFireDAC1.Connection := FDConnection1;
6192BoldPersistenceHandleDB1.DatabaseAdapter := BoldDatabaseAdapterFireDAC1;
6293```
6394
64- ### Supported Databases
95+ ### Supported Persistence Targets
6596
66- | Database | Adapter |
67- | ---------- | ---------|
97+ | Target | Adapter |
98+ | --------| ---------|
6899| SQL Server | FireDAC, UniDAC |
69100| PostgreSQL | FireDAC, UniDAC |
70101| InterBase | FireDAC |
71102| Oracle | FireDAC, UniDAC |
72103| SQLite | FireDAC |
104+ | XML | BoldPersistenceHandleFileXML |
73105
74106## Operations
75107
76108### Save Changes
77-
78109``` pascal
79110// Save all dirty objects to database
80111BoldSystemHandle1.UpdateDatabase;
@@ -86,7 +117,6 @@ BoldSystemHandle1.System.UpdateDatabase;
86117### Fetch Objects
87118
88119Bold fetches objects lazily by default:
89-
90120``` pascal
91121// Objects loaded on first access
92122Customer := Customers[0]; // Fetches from DB if not loaded
@@ -96,7 +126,6 @@ Name := Customer.Name; // Attribute already loaded
96126### Batch Fetching
97127
98128For performance, prefetch related objects:
99-
100129``` pascal
101130// Fetch customers and their orders in one query
102131BoldSystemHandle1.System.FetchLinksWithObjects(
@@ -108,7 +137,6 @@ BoldSystemHandle1.System.FetchLinksWithObjects(
108137## Transactions
109138
110139### Basic Transaction
111-
112140``` pascal
113141BoldSystem.StartTransaction;
114142try
@@ -131,13 +159,13 @@ Bold supports nested transactions with savepoints.
131159## Schema Evolution
132160
133161Bold can evolve your database schema when the model changes:
134-
135162``` pascal
136163// Use DbEvolutor to generate migration scripts
137164BoldDbEvolutor1.GenerateScript;
138165```
139166
140167Changes handled:
168+
141169- Add/remove classes (tables)
142170- Add/remove attributes (columns)
143171- Modify attribute types
@@ -148,4 +176,4 @@ Changes handled:
1481761 . ** Use batch fetching** for collections you'll iterate
1491772 . ** Avoid N+1 queries** by prefetching associations
1501783 . ** Use OCL efficiently** - filter in database when possible
151- 4 . ** Index foreign keys** for faster association traversal
179+ 4 . ** Index foreign keys** for faster association traversal
0 commit comments