mike@159: /* mike@159: * Copyright 2020 Mike Becker. All rights reserved. mike@159: * mike@159: * Redistribution and use in source and binary forms, with or without mike@159: * modification, are permitted provided that the following conditions are met: mike@159: * mike@159: * 1. Redistributions of source code must retain the above copyright mike@159: * notice, this list of conditions and the following disclaimer. mike@159: * mike@159: * 2. Redistributions in binary form must reproduce the above copyright mike@159: * notice, this list of conditions and the following disclaimer in the mike@159: * documentation and/or other materials provided with the distribution. mike@159: * mike@159: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" mike@159: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE mike@159: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE mike@159: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE mike@159: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL mike@159: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR mike@159: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER mike@159: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, mike@159: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE mike@159: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. mike@159: * mike@159: */ mike@159: mike@159: package de.uapcore.lightpit.dao mike@159: mike@159: abstract class AbstractEntityDao : AbstractDao() { mike@159: mike@159: /** mike@159: * Lists all entities. mike@159: * @return a list of all entities mike@159: */ mike@159: abstract fun list(): List mike@159: mike@159: /** mike@159: * Finds an entity by its integer ID. mike@159: * It is not guaranteed that referenced entities are automatically joined. mike@159: * mike@159: * @param id the id mike@159: * @return the entity or null if there is no such entity mike@159: */ mike@159: abstract fun find(id: Int): T? mike@159: mike@159: /** mike@159: * Inserts an instance into database. mike@159: * It is not guaranteed that generated fields will be updated in the instance. mike@159: * mike@159: * @param instance the instance to insert mike@159: */ mike@159: abstract fun save(instance: T) mike@159: mike@159: /** mike@159: * Updates an instance in the database. mike@159: * mike@159: * @param instance the instance to update mike@159: * @return true if an instance has been updated, false if the instance is not present in database mike@159: */ mike@159: abstract fun update(instance: T): Boolean mike@159: }