Interface CrudDao<T,ID,SB extends com.landawn.abacus.util.SQLBuilder,TD extends CrudDao<T,ID,SB,TD>>

Type Parameters:
T -
ID - use Void if there is no id defined/annotated with @Id in target entity class T.
SB - SQLBuilder used to generate sql scripts. Only can be SQLBuilder.PSC/PAC/PLC
All Superinterfaces:
Dao<T,SB,TD>
All Known Subinterfaces:
CrudDaoL<T,SB,TD>, NoUpdateCrudDao<T,ID,SB,TD>, NoUpdateCrudDaoL<T,SB,TD>, ReadOnlyCrudDao<T,ID,SB,TD>, ReadOnlyCrudDaoL<T,SB,TD>, UncheckedCrudDao<T,ID,SB,TD>, UncheckedCrudDaoL<T,SB,TD>, UncheckedNoUpdateCrudDao<T,ID,SB,TD>, UncheckedNoUpdateCrudDaoL<T,SB,TD>, UncheckedReadOnlyCrudDao<T,ID,SB,TD>, UncheckedReadOnlyCrudDaoL<T,SB,TD>

public interface CrudDao<T,ID,SB extends com.landawn.abacus.util.SQLBuilder,TD extends CrudDao<T,ID,SB,TD>> extends Dao<T,SB,TD>
The Interface CrudDao.
See Also:
  • Method Details

    • idExtractor

      default Jdbc.BiRowMapper<ID> idExtractor()
    • generateId

      Deprecated.
      unsupported Operation
      Returns:
      Throws:
      UnsupportedOperationException
      SQLException
    • insert

      ID insert(T entityToInsert) throws SQLException
      Parameters:
      entityToInsert -
      Returns:
      Throws:
      SQLException
    • insert

      ID insert(T entityToInsert, Collection<String> propNamesToInsert) throws SQLException
      Parameters:
      entityToInsert -
      propNamesToInsert -
      Returns:
      Throws:
      SQLException
    • insert

      ID insert(String namedInsertSQL, T entityToInsert) throws SQLException
      Parameters:
      namedInsertSQL -
      entityToInsert -
      Returns:
      Throws:
      SQLException
    • batchInsert

      default List<ID> batchInsert(Collection<? extends T> entities) throws SQLException
      Parameters:
      entities -
      Returns:
      Throws:
      SQLException
    • batchInsert

      List<ID> batchInsert(Collection<? extends T> entities, int batchSize) throws SQLException
      Parameters:
      entities -
      batchSize -
      Returns:
      Throws:
      SQLException
    • batchInsert

      default List<ID> batchInsert(Collection<? extends T> entities, Collection<String> propNamesToInsert) throws SQLException
      Parameters:
      entities -
      propNamesToInsert -
      Returns:
      Throws:
      SQLException
    • batchInsert

      List<ID> batchInsert(Collection<? extends T> entities, Collection<String> propNamesToInsert, int batchSize) throws SQLException
      Parameters:
      entities -
      propNamesToInsert -
      batchSize -
      Returns:
      Throws:
      SQLException
    • batchInsert

      @Beta default List<ID> batchInsert(String namedInsertSQL, Collection<? extends T> entities) throws SQLException
      Parameters:
      namedInsertSQL -
      entities -
      Returns:
      Throws:
      SQLException
    • batchInsert

      @Beta List<ID> batchInsert(String namedInsertSQL, Collection<? extends T> entities, int batchSize) throws SQLException
      Parameters:
      namedInsertSQL -
      entities -
      batchSize -
      Returns:
      Throws:
      SQLException
    • queryForBoolean

      com.landawn.abacus.util.u.OptionalBoolean queryForBoolean(String singleSelectPropName, ID id) throws SQLException
      Query for boolean.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForChar

      com.landawn.abacus.util.u.OptionalChar queryForChar(String singleSelectPropName, ID id) throws SQLException
      Query for char.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForByte

      com.landawn.abacus.util.u.OptionalByte queryForByte(String singleSelectPropName, ID id) throws SQLException
      Query for byte.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForShort

      com.landawn.abacus.util.u.OptionalShort queryForShort(String singleSelectPropName, ID id) throws SQLException
      Query for short.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForInt

      com.landawn.abacus.util.u.OptionalInt queryForInt(String singleSelectPropName, ID id) throws SQLException
      Query for int.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForLong

      com.landawn.abacus.util.u.OptionalLong queryForLong(String singleSelectPropName, ID id) throws SQLException
      Query for long.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForFloat

      com.landawn.abacus.util.u.OptionalFloat queryForFloat(String singleSelectPropName, ID id) throws SQLException
      Query for float.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForDouble

      com.landawn.abacus.util.u.OptionalDouble queryForDouble(String singleSelectPropName, ID id) throws SQLException
      Query for double.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForString

      com.landawn.abacus.util.u.Nullable<String> queryForString(String singleSelectPropName, ID id) throws SQLException
      Query for string.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForDate

      com.landawn.abacus.util.u.Nullable<Date> queryForDate(String singleSelectPropName, ID id) throws SQLException
      Query for date.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForTime

      com.landawn.abacus.util.u.Nullable<Time> queryForTime(String singleSelectPropName, ID id) throws SQLException
      Query for time.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForTimestamp

      com.landawn.abacus.util.u.Nullable<Timestamp> queryForTimestamp(String singleSelectPropName, ID id) throws SQLException
      Query for timestamp.
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForBytes

      com.landawn.abacus.util.u.Nullable<byte[]> queryForBytes(String singleSelectPropName, ID id) throws SQLException
      Query for byte[].
      Parameters:
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForSingleResult

      <V> com.landawn.abacus.util.u.Nullable<V> queryForSingleResult(Class<? extends V> targetValueClass, String singleSelectPropName, ID id) throws SQLException
      Query for single result.
      Type Parameters:
      V - the value type
      Parameters:
      targetValueClass -
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForSingleNonNull

      <V> com.landawn.abacus.util.u.Optional<V> queryForSingleNonNull(Class<? extends V> targetValueClass, String singleSelectPropName, ID id) throws SQLException
      Query for single non null.
      Type Parameters:
      V - the value type
      Parameters:
      targetValueClass -
      singleSelectPropName -
      id -
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or idition).
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForUniqueResult

      <V> com.landawn.abacus.util.u.Nullable<V> queryForUniqueResult(Class<? extends V> targetValueClass, String singleSelectPropName, ID id) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Query for unique result.
      Type Parameters:
      V - the value type
      Parameters:
      targetValueClass -
      singleSelectPropName -
      id -
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or idition).
      SQLException
      See Also:
      • IDFactory
      • IDFactory.CF
    • queryForUniqueNonNull

      <V> com.landawn.abacus.util.u.Optional<V> queryForUniqueNonNull(Class<? extends V> targetValueClass, String singleSelectPropName, ID id) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Query for unique non null.
      Type Parameters:
      V - the value type
      Parameters:
      targetValueClass -
      singleSelectPropName -
      id -
      Returns:
      Throws:
      SQLException
      com.landawn.abacus.exception.DuplicatedResultException
      See Also:
      • IDFactory
      • IDFactory.CF
    • get

      default com.landawn.abacus.util.u.Optional<T> get(ID id) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      id -
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
      SQLException
    • get

      default com.landawn.abacus.util.u.Optional<T> get(ID id, Collection<String> selectPropNames) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      id -
      selectPropNames - all properties(columns) will be selected, excluding the properties of joining entities, if the specified selectPropNames is null.
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
      SQLException
    • gett

      T gett(ID id) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      id -
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
      SQLException
    • gett

      T gett(ID id, Collection<String> selectPropNames) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      id -
      selectPropNames - all properties(columns) will be selected, excluding the properties of joining entities, if the specified selectPropNames is null.
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if more than one record found by the specified id (or condition).
      SQLException
    • batchGet

      default List<T> batchGet(Collection<? extends ID> ids) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      ids -
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if the size of result is bigger than the size of input ids.
      SQLException
    • batchGet

      default List<T> batchGet(Collection<? extends ID> ids, int batchSize) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      ids -
      batchSize -
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if the size of result is bigger than the size of input ids.
      SQLException
    • batchGet

      default List<T> batchGet(Collection<? extends ID> ids, Collection<String> selectPropNames) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      ids -
      selectPropNames - all properties(columns) will be selected, excluding the properties of joining entities, if the specified selectPropNames is null. all properties(columns) will be selected, excluding the properties of joining entities, if the specified selectPropNames is null.
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if the size of result is bigger than the size of input ids.
      SQLException
    • batchGet

      List<T> batchGet(Collection<? extends ID> ids, Collection<String> selectPropNames, int batchSize) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException
      Parameters:
      ids -
      selectPropNames - all properties(columns) will be selected, excluding the properties of joining entities, if the specified selectPropNames is null. all properties(columns) will be selected, excluding the properties of joining entities, if selectPropNames is null.
      batchSize -
      Returns:
      Throws:
      com.landawn.abacus.exception.DuplicatedResultException - if the size of result is bigger than the size of input ids.
      SQLException
    • exists

      boolean exists(ID id) throws SQLException
      Parameters:
      id -
      Returns:
      true, if successful
      Throws:
      SQLException
      See Also:
    • notExists

      @Beta default boolean notExists(ID id) throws SQLException
      Parameters:
      id -
      Returns:
      Throws:
      SQLException
      See Also:
    • count

      @Beta int count(Collection<? extends ID> ids) throws SQLException
      Count the records in db by input ids.
      Parameters:
      ids -
      Returns:
      Throws:
      SQLException
    • update

      int update(T entityToUpdate) throws SQLException
      Parameters:
      entityToUpdate -
      Returns:
      Throws:
      SQLException
    • update

      int update(T entityToUpdate, Collection<String> propNamesToUpdate) throws SQLException
      Parameters:
      entityToUpdate -
      propNamesToUpdate -
      Returns:
      Throws:
      SQLException
    • update

      default int update(String propName, Object propValue, ID id) throws SQLException
      Parameters:
      propName -
      propValue -
      id -
      Returns:
      Throws:
      SQLException
    • update

      int update(Map<String,Object> updateProps, ID id) throws SQLException
      Parameters:
      updateProps -
      id -
      Returns:
      Throws:
      SQLException
    • batchUpdate

      default int batchUpdate(Collection<? extends T> entities) throws SQLException
      Parameters:
      entities -
      Returns:
      Throws:
      SQLException
    • batchUpdate

      int batchUpdate(Collection<? extends T> entities, int batchSize) throws SQLException
      Parameters:
      entities -
      batchSize -
      Returns:
      Throws:
      SQLException
    • batchUpdate

      default int batchUpdate(Collection<? extends T> entities, Collection<String> propNamesToUpdate) throws SQLException
      Parameters:
      entities -
      propNamesToUpdate -
      Returns:
      Throws:
      SQLException
    • batchUpdate

      int batchUpdate(Collection<? extends T> entities, Collection<String> propNamesToUpdate, int batchSize) throws SQLException
      Parameters:
      entities -
      propNamesToUpdate -
      batchSize -
      Returns:
      Throws:
      SQLException
    • upsert

      default T upsert(T entity, com.landawn.abacus.condition.Condition cond) throws SQLException
      Execute add and return the added entity if the record doesn't, otherwise, update is executed and updated db record is returned.
      Specified by:
      upsert in interface Dao<T,ID,SB extends com.landawn.abacus.util.SQLBuilder>
      Parameters:
      entity -
      cond - to verify if the record exists or not.
      Returns:
      Throws:
      SQLException
      See Also:
      • ConditionFactory
      • ConditionFactory.CF
    • upsert

      default T upsert(T entity) throws SQLException
      Execute add and return the added entity if the record doesn't, otherwise, update is executed and updated db record is returned.
      Parameters:
      entity -
      Returns:
      Throws:
      SQLException
    • batchUpsert

      default List<T> batchUpsert(Collection<? extends T> entities) throws SQLException
      Parameters:
      entities -
      Returns:
      Throws:
      SQLException
    • batchUpsert

      default List<T> batchUpsert(Collection<? extends T> entities, int batchSize) throws SQLException
      Parameters:
      entities -
      batchSize -
      Returns:
      Throws:
      SQLException
    • refresh

      default boolean refresh(T entity) throws SQLException
      Parameters:
      entity -
      Returns:
      true, if successful
      Throws:
      SQLException
    • refresh

      default boolean refresh(T entity, Collection<String> propNamesToRefresh) throws SQLException
      Parameters:
      entity -
      propNamesToRefresh -
      Returns:
      false if no record found by the ids in the specified entity.
      Throws:
      SQLException
    • batchRefresh

      default int batchRefresh(Collection<? extends T> entities) throws SQLException
      Parameters:
      entities -
      Returns:
      the count of refreshed entities.
      Throws:
      SQLException
    • batchRefresh

      default int batchRefresh(Collection<? extends T> entities, int batchSize) throws SQLException
      Parameters:
      entities -
      batchSize -
      Returns:
      the count of refreshed entities.
      Throws:
      SQLException
    • batchRefresh

      default int batchRefresh(Collection<? extends T> entities, Collection<String> propNamesToRefresh) throws SQLException
      Parameters:
      entities -
      propNamesToRefresh -
      Returns:
      the count of refreshed entities.
      Throws:
      SQLException
    • batchRefresh

      default int batchRefresh(Collection<? extends T> entities, Collection<String> propNamesToRefresh, int batchSize) throws SQLException
      Parameters:
      entities -
      propNamesToRefresh -
      batchSize -
      Returns:
      the count of refreshed entities.
      Throws:
      SQLException
    • delete

      int delete(T entity) throws SQLException
      Parameters:
      entity -
      Returns:
      Throws:
      SQLException
    • deleteById

      int deleteById(ID id) throws SQLException
      Delete by id.
      Parameters:
      id -
      Returns:
      Throws:
      SQLException
    • batchDelete

      default int batchDelete(Collection<? extends T> entities) throws SQLException
      Parameters:
      entities -
      Returns:
      Throws:
      SQLException
    • batchDelete

      int batchDelete(Collection<? extends T> entities, int batchSize) throws SQLException
      Parameters:
      entities -
      batchSize -
      Returns:
      Throws:
      SQLException
    • batchDeleteByIds

      default int batchDeleteByIds(Collection<? extends ID> ids) throws SQLException
      Parameters:
      ids -
      Returns:
      Throws:
      SQLException
    • batchDeleteByIds

      int batchDeleteByIds(Collection<? extends ID> ids, int batchSize) throws SQLException
      Parameters:
      ids -
      batchSize -
      Returns:
      Throws:
      SQLException