English | 简体中文

api-docs / org.ktorm.schema / BaseTable / createEntity


fun createEntity(
    row: QueryRowSet,
    withReferences: Boolean = true
): E
(source code)

Create an entity object from the specific row of query results. This function uses the binding configurations
of the table, filling column values into corresponding properties of the returned entity.

If the withReferences flag is set to true and there are any reference bindings to other tables, this function
will create the referenced entity objects by recursively calling createEntity itself.

Otherwise if the withReferences flag is set to false, it will threat all reference bindings as nested bindings
to the referenced entities’ primary keys. For example the binding c.references(Departments) { it.department },
it is equivalent to c.bindTo { it.department.id } in this case, that avoids unnecessary object creations
and some exceptions raised by conflict column names.