Annotations
Kiln provides four annotations. All have SOURCE retention — they are consumed entirely at compile time and produce no runtime overhead.
| Annotation | Target | Purpose |
|---|---|---|
@DbEntity |
Class | Marks a data class as a database table |
@PrimaryKey |
Property | Designates a primary key column — two or more form a composite key |
@Column |
Property | Overrides column name, adds constraints, hints migration |
@Ignore |
Property | Excludes a property from the schema |
@Relation |
Property | Marks a FK property; generates findBy<Parent>, observeBy<Parent>, deleteBy<Parent> |
Minimal example
@DbEntity(tableName = "products")
data class Product(
@PrimaryKey(autoGenerate = true) val id: Long = 0, // (1)!
val name: String, // (2)!
@Column(name = "price_cents") val price: Long, // (3)!
@Column(unique = true) val sku: String, // (4)!
@Ignore val displayPrice: String = "" // (5)!
)
- Auto-generated integer PK — pass
id = 0on insert, SQLite assigns the real id. - No
@Columnneeded — property name is used as column name as-is. @Column(name = …)overrides the column name in SQLite.@Column(unique = true)adds aUNIQUEconstraint.@Ignore— not stored, not read back from the database.
What gets generated
For Product above, Kiln generates:
ProductRepository— all CRUD, reactive, and DSL methodsProductColumns— typedColumn<T>references for use in DSL queries: