Table types
tip
While
Table
is the foundational class for defining tables in DSL, you can also use theIdTable
subclasses from the DAO API for convenience. For example, to provide an auto-incrementingid
column of typeInt
, you can use theIntIdTable
subtype:object StarWarsFilmsTable : IntIdTable() { val sequelId = integer("sequel_id").uniqueIndex() val name = varchar("name", MAX_VARCHAR_LENGTH) val director = varchar("director", MAX_VARCHAR_LENGTH) }
It is important to note that the
id
column in this case is of typeColumn<EntityID<Int>>
. TheEntityID
wrapper ensures that theid
values are handled consistently across the DSL and DAO APIs.To access the
id
column value, you need to use the.value
property:val movieId: Int = movie.id.value
For more information on
IdTable
, see the DAO documentation.