flushChanges
Update the property changes of this entity into the database and return the affected record number.
Using this function, we need to note that:
This function requires a primary key specified in the table object via Table.primaryKey, otherwise Ktorm doesn't know how to identify entity objects and will throw an exception.
The entity object calling this function must be ATTACHED to the database first. In Ktorm’s implementation, every entity object holds a reference
fromDatabase
. For entity objects obtained by sequence APIs, theirfromDatabase
references point to the database they are obtained from. For entity objects created by Entity.create or Entity.Factory, theirfromDatabase
references arenull
initially, so we can not call flushChanges on them. But once we use them with add or update function,fromDatabase
will be modified to the current database, so we will be able to call flushChanges on them afterward.