Allan Wang
05/22/2018, 4:16 PMfun <ID : Comparable<ID>, T : Entity<ID>> EntityClass<ID, T>.newOrUpdate(id: ID, update: T.() -> Unit): T {
val existing = findById(id)
return if (existing != null) existing.apply(update)
else new(id, update)
}
But there is an unnecessary query if the entity isn't cached. This method aims to just end up with a new entity with the supplied id, regardless of whether it exists alreadytapac
05/22/2018, 4:33 PM