en un clic
entity-mapping
// SimpleORM entity-to-database mapping via RTTI attributes. Complete reference for all attributes, property types, and relationship setup.
// SimpleORM entity-to-database mapping via RTTI attributes. Complete reference for all attributes, property types, and relationship setup.
Validates all SimpleORM Delphi source files for Delphi 10.2 Tokyo+ compatibility. Checks inline vars, unit scoping, generics E2506, uses completeness, memory safety, .dpr structure, and conditional compilation. Run anytime to "lint" the project.
Delphi project file structure reference — .dpr vs .pas, .dproj, .res, .dfm. Templates for console and VCL projects.
CHANGELOG.md format reference and examples for the SimpleORM project.
Coding conventions and patterns for the SimpleORM Delphi project. Automatically loaded when writing or modifying Delphi code.
Horse/ExpxHorse integration patterns for SimpleORM — server auto-routing, client REST driver, serialization examples.
The exact iSimpleQuery interface contract that all query drivers must implement. Reference for creating or reviewing drivers.
| name | entity-mapping |
| description | SimpleORM entity-to-database mapping via RTTI attributes. Complete reference for all attributes, property types, and relationship setup. |
| user-invocable | false |
Rules are in
.claude/rules/entity-mapping.md— this skill provides reference and templates.
[Tabela('TABLE_NAME')]
TMyEntity = class
private
FId: Integer;
FName: String;
procedure SetId(const Value: Integer);
procedure SetName(const Value: String);
public
constructor Create;
destructor Destroy; override;
published
[Campo('ID'), PK, AutoInc]
property Id: Integer read FId write SetId;
[Campo('NAME'), NotNull]
property Name: String read FName write SetName;
end;
| Attribute | Target | Purpose |
|---|---|---|
Tabela('NAME') | class | Maps to database table |
Campo('NAME') | property | Maps to column name |
| Attribute | Purpose |
|---|---|
PK | Primary key (exactly one) |
FK | Foreign key |
AutoInc | Auto-increment (excluded from INSERT) |
| Attribute | Purpose |
|---|---|
NotNull | Required field |
NotZero | Numeric cannot be zero |
Ignore | Skip in all SQL operations |
Email | Validates email format |
MinValue(n) | Minimum numeric value |
MaxValue(n) | Maximum numeric value |
Regex('pattern', 'msg') | Custom regex validation |
Format(maxSize, precision) | Size/precision constraints |
| Attribute | Purpose |
|---|---|
Display('Label') | Display name for grids/forms |
Bind('FIELD') | Binds form component |
NumberOnly | Numeric-only input |
| Attribute | Cardinality | Loading |
|---|---|---|
HasOne('Entity', 'FK') | 1:1 | Eager |
BelongsTo('Entity', 'FK') | N:1 | Eager |
HasMany('Entity', 'FK') | 1:N | Lazy (TSimpleLazyLoader) |
BelongsToMany('Entity', 'FK') | M:N | Manual |
| Attribute | Purpose |
|---|---|
SoftDelete('FIELD') | On class — logical deletion |
Enumerator('TYPE') | PostgreSQL enum cast |
| Delphi Type | JSON Serialization | DB Param Type |
|---|---|---|
String | string | ftString |
Integer | number | ftInteger |
Int64 | number | ftLargeint |
Double | number | ftFloat |
TDateTime | ISO8601 string | ftDateTime |
Boolean | true/false | ftBoolean |
HasOne/BelongsTo — eager loaded by DAO:
[HasOne('PEDIDO', 'ID_PEDIDO')]
property Pedido: TPedido read FPedido write SetPedido;
HasMany — lazy loaded:
uses SimpleProxy;
FItens := TSimpleLazyLoader<TItemPedido>.Create(Query, 'ID_PEDIDO', Self.Id);
Entity class → TSimpleRTTI<T> extracts:
.TableName → reads [Tabela] attribute
.Fields → iterates published properties with [Campo]
.PrimaryKey → finds property with [PK]
.Where → builds PK = :PK condition
.FieldsInsert → Fields minus [AutoInc]
.SoftDeleteField → reads [SoftDelete] from class