← Back to Stormify Documentation

attach

fun <T : StormifyEntity> attach(target: T): T

Attaches this Stormify instance to the entity target, so it lazy-loads and writes through this instance. Entities this instance reads are attached already. Returns target for fluent chaining.

// Manual stub: the id is known, the rest loads on first access
val user = stormify.attach(User().apply { id = 42 })
println(user.name) // triggers SELECT via the attached instance