de.esprit.appsuite.database.dbase

## Interface Database

- All Known Implementing Classes:
    LocalDatabase, RemoteDatabase

      public interface Database

  This interface defines database actions for DBRecord instances. An implementing class may perform these actions either locally or remote. Note that the handleError flag controls whether an error message should popup in case of failure.
  Author:
    Rainer Buesch

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dbDelete(DBRecord... records)` Performs a database request that to delete the given record(s) from the database.
    `DBRecord` | `dbInsert(DBRecord record)` Inserts the record into the database.
    `DBRecord[]` | `dbInsertRecords(DBRecord... records)` Performs a database request to insert the given records into the database.
    `void` | `dbLoadRecords(DBRecord master, DBLoadMonitor monitor, SqlCondition condition)` Same as `dbLoadRecords(DBRecord, DBLoadMonitor, SqlCondition)`.
    `void` | `dbLoadRecords(DBRecord master, DBLoadMonitor monitor, SqlCondition condition, SqlOrder order)` Performs a database request to load records of the given type with the given condition and order.
    `DBRecord` | `dbRehash(DBRecord record)` Performs a database request to rehash the given record.
    `DBRecord[]` | `dbRehashRecords(DBRecord... record)` Performs a database request that tries to rehash the given records.
    `DBRecord[]` | `dbSearchRecords(DBRecord master, SqlCondition condition, SqlOrder order)` Performs a database request to select `ComposedRecord` instances by a `SqlCondition` that may contain fields of different record parts (the composing DBObjects).
    `DBRecord` | `dbSelect(DBRecord master, java.lang.String... primaryKey)` Performs a database request to fetch a single record by primary key.
    `DBRecord[]` | `dbSelectRecords(DBRecord master, SqlCondition condition)` Same as `dbSelectRecords(DBRecord, SqlCondition, SqlOrder)`.
    `DBRecord[]` | `dbSelectRecords(DBRecord master, SqlCondition condition, SqlOrder order)` Performs a database request to read records of the given type with the given condition and order.
    `DBObject` | `dbStore(DBObject dbo)` Performs a database request to store the given DBobject with its `DBObject.forceUpdate()` method.
    `DBObject[]` | `dbStoreRecords(DBObject... dbos)` Performs a database request to store the given records with their `DBObject.forceUpdate()` method.
    `void` | `dbUpdate(DBRecord... records)` Performs a database request to update the given record(s) in the database.

- - ### Method Detail

    - #### dbInsert

          DBRecord dbInsert(DBRecord record)
                            throws java.lang.Exception

      Inserts the record into the database. Note that the inserted record may have got a primary key as well as default field values from the database
      Returns:
        The inserted record, with dirty state reset to clean.
      Throws:
        `java.lang.Exception`
      See Also:
        `dbInsertRecords(DBRecord[])`

    - #### dbInsertRecords

          DBRecord[] dbInsertRecords(DBRecord... records)
                                     throws java.lang.Exception

      Performs a database request to insert the given records into the database. Note that the inserted records may have got a new primary key assigned and default field values may have been set by the database.
      Returns:
        An array of the inserted records, with dirty state reset to clean.
      Throws:
        `java.lang.Exception`

    - #### dbUpdate

          void dbUpdate(DBRecord... records)
                        throws java.lang.Exception

      Performs a database request to update the given record(s) in the database.
      Throws:
        `java.lang.Exception`

    - #### dbDelete

          void dbDelete(DBRecord... records)
                        throws java.lang.Exception

      Performs a database request that to delete the given record(s) from the database. Note that not finding the record is not considered to be an error condition. In this case the record will just be set to dirty state.
      Throws:
        `java.lang.Exception`

    - #### dbRehash

          DBRecord dbRehash(DBRecord record)
                            throws java.lang.Exception

      Performs a database request to rehash the given record.
      Returns:
        The rehashed record whereas its dirty state has been reset to clean..
      Throws:
        `java.lang.Exception`
      See Also:
        `dbRehashRecords(DBRecord[])`

    - #### dbRehashRecords

          DBRecord[] dbRehashRecords(DBRecord... record)
                                     throws java.lang.Exception

      Performs a database request that tries to rehash the given records.
      Returns:
        The rehashed records whereas their dirty state has been reset to clean.
      Throws:
        `java.lang.Exception`

    - #### dbLoadRecords

          void dbLoadRecords(DBRecord master,
                           DBLoadMonitor monitor,
                           SqlCondition condition,
                           SqlOrder order)
                             throws java.lang.Exception

      Performs a database request to load records of the given type with the given condition and order. The `DBLoadMonitor` is responsible for collecting or processing the records.
      Throws:
        `java.lang.Exception`

    - #### dbLoadRecords

          void dbLoadRecords(DBRecord master,
                           DBLoadMonitor monitor,
                           SqlCondition condition)
                             throws java.lang.Exception

      Same as `dbLoadRecords(DBRecord, DBLoadMonitor, SqlCondition)`. The default order is by primary key.
      Throws:
        `java.lang.Exception`

    - #### dbSelectRecords

          DBRecord[] dbSelectRecords(DBRecord master,
                                   SqlCondition condition,
                                   SqlOrder order)
                                     throws java.lang.Exception

      Performs a database request to read records of the given type with the given condition and order. An empty array is returned if no records were found.
      Returns:
        The matching records, an empty array if no records were found.
      Throws:
        `java.lang.Exception`

    - #### dbSelectRecords

          DBRecord[] dbSelectRecords(DBRecord master,
                                   SqlCondition condition)
                                     throws java.lang.Exception

      Same as `dbSelectRecords(DBRecord, SqlCondition, SqlOrder)`. The default order is by primary key.
      Returns:
        The matching records, an empty array if no records were found.
      Throws:
        `java.lang.Exception`

    - #### dbSelect

          DBRecord dbSelect(DBRecord master,
                          java.lang.String... primaryKey)
                            throws java.lang.Exception

      Performs a database request to fetch a single record by primary key.
      Returns:
        The matching record, null if not found.
      Throws:
        `java.lang.Exception`

    - #### dbSearchRecords

          DBRecord[] dbSearchRecords(DBRecord master,
                                   SqlCondition condition,
                                   SqlOrder order)
                                     throws java.lang.Exception

      Performs a database request to select `ComposedRecord` instances by a `SqlCondition` that may contain fields of different record parts (the composing DBObjects). The statement typically performs a join on several tables. Note that classes with composed primary keys are not supported yet.
      Returns:
        The matching composed records, an empty array if none were found.
      Throws:
        `java.lang.Exception`

    - #### dbStore

          DBObject dbStore(DBObject dbo)
                           throws java.lang.Exception

      Performs a database request to store the given DBobject with its `DBObject.forceUpdate()` method. If the record exists already it will be updated, otherwise it will be inserted.
      Returns:
        The stored record.
      Throws:
        `java.lang.Exception`
      See Also:
        `dbStoreRecords(DBObject[])`

    - #### dbStoreRecords

          DBObject[] dbStoreRecords(DBObject... dbos)
                                    throws java.lang.Exception

      Performs a database request to store the given records with their `DBObject.forceUpdate()` method. If the records exist already they will be updated, otherwise they will be inserted. Note that this only works on DBObjects and not on composed records.
      Returns:
        The stored DBObjects.
      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.