Interface ISqlJetTable

  • All Known Implementing Classes:
    SqlJetTable

    public interface ISqlJetTable
    Interface which represents database table.
    Author:
    TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
    • Method Detail

      • getDataBase

        SqlJetDb getDataBase()
        Get database connection.
        Returns:
        the database connection.
      • getIndexesNames

        java.util.Set<java.lang.String> getIndexesNames()
                                                 throws SqlJetException
        Get table indexes names.
        Returns:
        names of table indexes.
        Throws:
        SqlJetException
      • open

        ISqlJetCursor open()
                    throws SqlJetException

        Open cursor for all table records.

        Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.

        Returns:
        cursor for all table records.
        Throws:
        SqlJetException
      • lookup

        ISqlJetCursor lookup​(java.lang.String indexName,
                             java.lang.Object... key)
                      throws SqlJetException

        Open cursor for records which have found by key on index.

        If indexName is NULL then primary key will be used.

        Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.

        Parameters:
        indexName - Name of the searched index. If null then primary key will be used.
        key - Key for the index lookup.
        Returns:
        cursor for records which have found by key on index.
        Throws:
        SqlJetException
      • order

        ISqlJetCursor order​(java.lang.String indexName)
                     throws SqlJetException

        Open cursors which sorts table by index.

        If indexName is NULL then primary key will be used.

        Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.

        Parameters:
        indexName - name of index which defines ordering.If null then primary key will be used.
        Returns:
        cursor sorted by index.
        Throws:
        SqlJetException
      • scope

        ISqlJetCursor scope​(java.lang.String indexName,
                            java.lang.Object[] firstKey,
                            java.lang.Object[] lastKey)
                     throws SqlJetException

        Open cursor which restricts table to some scope of index values.

        Scope is specified as pair of index keys. First key means start of scope and last key means end of scope. One of these keys (or even both) could be NULL. In this case scope is open from one side (or both sides). If first key is less of last key then cursor will be in reversed order. If indexName is NULL then primary key will be used.

        Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.

        Parameters:
        indexName - Name of the searched index. If null then primary key will be used.
        firstKey - first key of scope. Could be NULL.
        lastKey - first key of scope. Could be NULL.
        Returns:
        cursor which have defined scope of rows.
        Throws:
        SqlJetException
      • scope

        ISqlJetCursor scope​(java.lang.String indexName,
                            SqlJetScope scope)
                     throws SqlJetException

        Open cursor which restricts table to some scope of index values.

        Scope is specified as pair of index keys. First key means start of scope and last key means end of scope. One of these keys (or even both) could be NULL. In this case scope is open from one side (or both sides). If first key is less of last key then cursor will be in reversed order. If indexName is NULL then primary key will be used.

        Cursors can be opened only within active transaction. When transaction ends all cursors will be closed.

        Parameters:
        indexName - Name of the searched index. If null then primary key will be used.
        scope - structure that contains both left and right bounds of the requested scope.
        Returns:
        cursor which have defined scope of rows.
        Throws:
        SqlJetException
      • insert

        long insert​(java.lang.Object... values)
             throws SqlJetException

        Add new record to the table with specified values.

        Values must be specified by position in table structure. If table have INTEGER PRIMARY KEY column then this column could be null and in this case it value will be defined automatically.

        If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.

        All relevant indexes are updated automatically.

        Returns ROWID of inserted record.

        Can be used without of active transaction, in this case method begins and ends own internal transaction.

        Parameters:
        values - Values for the new record.
        Returns:
        ROWID of inserted record.
        Throws:
        SqlJetException
      • insertByFieldNames

        long insertByFieldNames​(java.util.Map<java.lang.String,​java.lang.Object> values)
                         throws SqlJetException

        Insert record by values by names of fields.

        If table have INTEGER PRIMARY KEY column then this column could be null or even not specified and in this case it value will be defined automatically.

        The ROWID of record could be passed by any of this names: ROWID, _ROWID_, OID. ROWID could be specified even if table haven't INTEGER PRIMARY KEY column.

        All relevant indexes are updated automatically.

        Returns ROWID of inserted record.

        Can be used without of active transaction, in this case method begins and ends own internal transaction.

        Parameters:
        values - map of field names with values.
        Returns:
        ROWID of inserted record.
        Throws:
        SqlJetException
      • insertWithRowId

        long insertWithRowId​(long rowId,
                             java.lang.Object... values)
                      throws SqlJetException

        Inserts record at specified rowId. If rowId is 0 then it generates new rowId.

        If table has INTEGER PRIMARY KEY column and rowId isn't 0 then value for this field will be ignored and could be specified just as null. If table has INTEGER PRIMARY KEY column and rowId is 0 then value for this field used as rowId.

        If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.

        All relevant indexes are updated automatically.

        Returns ROWID of inserted record.

        Can be used without of active transaction, in this case method begins and ends own internal transaction.

        Parameters:
        rowId - ROWID of record.
        values - Values for the new record.
        Throws:
        SqlJetException
      • insertOr

        long insertOr​(SqlJetConflictAction onConflict,
                      java.lang.Object... values)
               throws SqlJetException

        Add new record to the table with specified values.

        Values must be specified by position in table structure.

        If table have INTEGER PRIMARY KEY column then this column could be null and in this case it value will be defined automatically.

        If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.

        All relevant indexes are updated automatically.

        Returns ROWID of inserted record.

        Can be used without of active transaction, in this case method begins and ends own internal transaction.

        Implements ON CONFLICT clause. See SqlJetConflictAction.

        Parameters:
        onConflict - SqlJetConflictAction.
        values - Values for the new record.
        Returns:
        ROWID of inserted record.
        Throws:
        SqlJetException
      • insertByFieldNamesOr

        long insertByFieldNamesOr​(SqlJetConflictAction onConflict,
                                  java.util.Map<java.lang.String,​java.lang.Object> values)
                           throws SqlJetException

        Insert record by values by names of fields.

        If table have INTEGER PRIMARY KEY column then this column could be null or even not specified and in this case it value will be defined automatically.

        The ROWID of record could be passed by any of this names: ROWID, _ROWID_, OID. ROWID could be specified even if table haven't INTEGER PRIMARY KEY column.

        All relevant indexes are updated automatically.

        Returns ROWID of inserted record.

        Can be used without of active transaction, in this case method begins and ends own internal transaction.

        Implements ON CONFLICT clause. See SqlJetConflictAction.

        Parameters:
        onConflict - SqlJetConflictAction.
        values - Values for the new record.
        Returns:
        ROWID of inserted record.
        Throws:
        SqlJetException
      • insertWithRowIdOr

        long insertWithRowIdOr​(SqlJetConflictAction onConflict,
                               long rowId,
                               java.lang.Object... values)
                        throws SqlJetException

        Inserts record at specified rowId.

        If rowId is 0 then it generates new rowId.

        If table has INTEGER PRIMARY KEY column and rowId isn't 0 then value for this field will be ignored and could be specified just as null. If table has INTEGER PRIMARY KEY column and rowId is 0 then value for this field used as rowId.

        If field has DEFAULT value then it could be passed as null. If fields have DEFAULT value and are last in table structure then they could be not specified.

        All relevant indexes are updated automatically.

        Returns ROWID of inserted record.

        Can be used without of active transaction, in this case method begins and ends own internal transaction.

        Implements ON CONFLICT clause. See SqlJetConflictAction.

        Parameters:
        onConflict - SqlJetConflictAction.
        rowId - ROWID of record.
        values - Values for the new record.
        Returns:
        ROWID of inserted record.
        Throws:
        SqlJetException