Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.db.makumba
Class DBConnectionWrapper

    java.lang.Object
      org.makumba.db.TransactionImplementation
          org.makumba.db.makumba.DBConnection
              org.makumba.db.makumba.DBConnectionWrapper

All Implemented Interfaces:
  Database, Transaction

Direct Known Subclasses:
  ClosedDBConnection

    public class DBConnectionWrapper

extends DBConnection

A wrapper for db connections, used to provide a temporary that holds a reference to a permanent DBConnection

Author:
  Cristian Bogdan, Stefan Baebler, Manuel Gay

Nested Class Summary

Nested classes/interfaces inherited from class org.makumba.db.makumba.DBConnection
`DBConnection.QueryAndArgs`

Field Summary
`(package private) Date` | `created`
`(package private) Throwable` | `t`
`(package private) DBConnection` | `wrapped`

Fields inherited from class org.makumba.db.makumba.DBConnection
`dataSource, db, lockRecord, locks, queries, whereDelim`

Fields inherited from class org.makumba.db.TransactionImplementation
`ddp, qp, tp`

Constructor Summary
`DBConnectionWrapper(DBConnection wrapped, String dataSource, TransactionProvider tp)`
`DBConnectionWrapper(TransactionProvider tp)`

Method Summary
`void` | `close()` Give this connection back to the system.
`void` | `commit()` Commit the transaction associated with this connection.
`void` | `delete(Pointer ptr)` Delete the record pointed by the given pointer.
`int` | `delete(String from, String where, Object parameters)` Deletes in the form delete("general.Person p", "p=$1", params) NOTE that this method does not delete subsets and subrecords
`Vector<Dictionary<String,Object>>` | `executeQuery(String OQL, Object parameterValues, int offset, int limit)` Execute a parametrized OQL query.
`protected void` | `finalize()`
`String` | `getCreationStack()`
`Database` | `getHostDatabase()`
`String` | `getName()` Get the name of the database in the form host[_port]_dbprotocol_dbname
`DBConnection` | `getWrapped()`
`Pointer` | `insert(Pointer host, String subsetField, Dictionary<String,Object> data)` Insert a record in a subset (1-N set) or subrecord (1-1 pointer) of the given record.
`Pointer` | `insert(String type, Dictionary<String,Object> data)` insert a record
`void` | `lock(String symbol)` Acquire a lock associated to the given application-specific symbol.
`Dictionary<String,Object>` | `read(Pointer ptr, Object fields)` Read fields of a record.
`void` | `rollback()` Rollback the transaction associated with this connection.
`void` | `setContext(Attributes a)`
`String` | `toString()`
`void` | `unlock(String symbol)` Free the lock on the given symbol, if any exists.
`int` | `update(Pointer ptr, Dictionary<String,Object> fieldsToChange)` change the record pointed by the given pointer.
`int` | `update(String from, String set, String where, Object parameters)` updates in the form update("general.Person p", "p.birthdate=$1", "p=$2", params) NOTE that this method does not delete subrecords if their pointers are nullified

Methods inherited from class org.makumba.db.makumba.DBConnection
`deleteLock, executeQuery, executeReadQuery, executeUpdate, getDataSource, getNullConstant, getQuery, insertFromQuery, setDataSource, unlockAll, writeReadQuery`

Methods inherited from class org.makumba.db.TransactionImplementation
`delete1, extractReadFields, getParameterName, getPrimaryKeyName, getPrimaryKeyName, getSetJoinSyntax, getTransactionProvider, paramsToMap, paramsToMap1, transformTypeName, treatParam`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### wrapped

    DBConnection wrapped

### t

    Throwable t

### created

    Date created

Constructor Detail

### DBConnectionWrapper

    DBConnectionWrapper(TransactionProvider tp)

### DBConnectionWrapper

    DBConnectionWrapper(DBConnection wrapped,
                        String dataSource,
                        TransactionProvider tp)

Method Detail

### getWrapped

    public DBConnection getWrapped()

### getName

    public String getName()

  Description copied from class: `DBConnection`
  Get the name of the database in the form host[_port]_dbprotocol_dbname

  Specified by:
    `getName` in interface `Database`
  Specified by:
    `getName` in interface `Transaction`
  Overrides:
    `getName` in class `DBConnection`

### getHostDatabase

    public Database getHostDatabase()

  Overrides:
    `getHostDatabase` in class `DBConnection`

### read

    public Dictionary<String,Object> read(Pointer ptr,
                                          Object fields)

  Description copied from interface: `Transaction`
  Read fields of a record. Database querying is logged (see `Logger`, `MakumbaSystem.setLoggingRoot(java.lang.String)`) in the `"db.query.compilation", "db.query.execution", "db.query.performance"` loggers, with `Level.INFO` logging level. "db.query.execution" also logs `Level.SEVERE` fatal errors.

  Specified by:
    `read` in interface `Database`
  Specified by:
    `read` in interface `Transaction`
  Overrides:
    `read` in class `TransactionImplementation`
  Parameters:
    `ptr` - the pointer to the record
    `fields` - the fields to read, or null to read all fields. Can be a String, String[], Enumeration or a Vector
  Returns:
    a Dictionary, containing a name-value pair for each non-null field, or null if the record doesn't exist

### executeQuery

    public Vector<Dictionary<String,Object>> executeQuery(String OQL,
                                                          Object parameterValues,
                                                          int offset,
                                                          int limit)

  Description copied from class: `DBConnection`
  Execute a parametrized OQL query.

  Specified by:
    `executeQuery` in interface `Database`
  Specified by:
    `executeQuery` in interface `Transaction`
  Overrides:
    `executeQuery` in class `DBConnection`
  Parameters:
    `OQL` - the query to execute. Refers to parameters as $1, $2 ...
    `parameterValues` - the arguments of the queries. Should be null if there are none. If there is only one parameter, it can be indicated directly. If there are more parameters, they can be indicated in a Object[] or a java.util.Vector. Named parameters can be indicated in a Map.
    `offset` - the offset of the first record to return, 0 for first
    `limit` - the maximum number of records to return, -1 for all
  Returns:
    a Vector of Dictionaries

### insert

    public Pointer insert(String type,
                          Dictionary<String,Object> data)

  Description copied from class: `DBConnection`
  insert a record

  Specified by:
    `insert` in interface `Database`
  Specified by:
    `insert` in interface `Transaction`
  Overrides:
    `insert` in class `DBConnection`
  Parameters:
    `type` - the makumba type to create a new record for
    `data` - the field-value mapping for the new record.
    The ommitted fields will be set to null.
    To insert an set of integets (set int {...}) pass a Vector of Integers. (or null, or an empty vector).
    To insert an set of strings (set char {...}) pass a Vector of String. (or null, or an empty vector).
    To refer to a field of base record or subrecord, indicate the pointer that leads to the record, and the respective field, like ptr1.ptr2.field. Every mentioned base record and subrecord will be inserted.
  Returns:
    a Pointer to the inserted record

### insert

    public Pointer insert(Pointer host,
                          String subsetField,
                          Dictionary<String,Object> data)

  Description copied from class: `TransactionImplementation`
  Insert a record in a subset (1-N set) or subrecord (1-1 pointer) of the given record. For 1-1 pointers, if another subrecord existed, it is deleted.

  Specified by:
    `insert` in interface `Database`
  Specified by:
    `insert` in interface `Transaction`
  Overrides:
    `insert` in class `TransactionImplementation`
  Parameters:
    `host` - a pointer to the host record, to which a subrecord will be added
    `subsetField` - the name of the subrecord field.
    `data` - the field-value mapping for the new subrecord.
    The ommitted fields will be set to null.
    To insert an external set, pass a Vector of Pointers (or null, or an empty vector).
    To insert an set of integets (set int {...}) pass a Vector of Integers. (or null, or an empty vector).
    To insert an set of strings (set char {...}) pass a Vector of String. (or null, or an empty vector).
    To refer to a field of a subrecord (subset members cannot have base records), indicate the pointer that leads to the record, and the respective field, like ptr1.ptr2.field.
  Returns:
    a Pointer to the inserted record

### update

    public int update(Pointer ptr,
                      Dictionary<String,Object> fieldsToChange)

  Description copied from class: `TransactionImplementation`
  change the record pointed by the given pointer. Only fields indicated are changed to the respective values

  Specified by:
    `update` in interface `Database`
  Specified by:
    `update` in interface `Transaction`
  Overrides:
    `update` in class `TransactionImplementation`
  Parameters:
    `ptr` - pointer to the record to update
    `fieldsToChange` - key-value pairs for the fields to modify.
    To nullify a field, pass the respective Null value from the Pointer class.
    To change an external set, pass a Vector of Pointers (an empty vector will empty the set).
    To change a set of integrers (set int{...}), pass a Vector of Integers (an empty vector will empty the set).
    To change a set of integrers (set char{...}), pass a Vector of Strings (an empty vector will empty the set).
    To refer to a field of a base record or subrecord, indicate the pointer that leads to the record, and the respective field, like ptr1.ptr2.field.
  See Also:
    `Pointer.Null`, `Pointer.NullInteger`, `Pointer.NullString`, `Pointer.NullText`, `Pointer.NullDate`, `Pointer.NullSet`

### update

    public int update(String from,
                      String set,
                      String where,
                      Object parameters)

  Description copied from class: `TransactionImplementation`
  updates in the form update("general.Person p", "p.birthdate=$1", "p=$2", params) NOTE that this method does not delete subrecords if their pointers are nullified

  Specified by:
    `update` in interface `Database`
  Specified by:
    `update` in interface `Transaction`
  Overrides:
    `update` in class `TransactionImplementation`
  Parameters:
    `from` - a makumba type in which update will take place, for example "general.Person p"
    `set` - the assignments made by the update, as OQL expression e.g. "p.birthdate=$1". Use "nil" for null assignments.
    `where` - the OQL conditions selecting the objects on which the update will be made, e.g. "p=$2"
    `parameters` - the parameter values. Should be null if there are no parameters. If there is only one parameter, it can be indicated directly. If there are more parameters, they can be indicated in a Object[] or a java.util.Vector
  Returns:
    the number of records affected

### delete

    public void delete(Pointer ptr)

  Description copied from class: `TransactionImplementation`
  Delete the record pointed by the given pointer. If the pointer is a 1-1, the oringinal is set to null. All the subrecords and subsets are automatically deleted.

  Specified by:
    `delete` in interface `Database`
  Specified by:
    `delete` in interface `Transaction`
  Overrides:
    `delete` in class `TransactionImplementation`
  Parameters:
    `ptr` - the pointer to the record to be deleted

### delete

    public int delete(String from,
                      String where,
                      Object parameters)

  Description copied from class: `TransactionImplementation`
  Deletes in the form delete("general.Person p", "p=$1", params) NOTE that this method does not delete subsets and subrecords

  Specified by:
    `delete` in interface `Database`
  Specified by:
    `delete` in interface `Transaction`
  Overrides:
    `delete` in class `TransactionImplementation`
  Parameters:
    `from` - a makumba type in which delete will take place, for example "general.Person p"
    `where` - the OQL conditions selecting the objects to be deleted, e.g. "p=$1"
    `parameters` - the parameter values. Should be null if there are no parameters. If there is only one parameter, it can be indicated directly. If there are more parameters, they can be indicated in a Object[] or a java.util.Vector
  Returns:
    the number of records affected

### commit

    public void commit()

  Description copied from interface: `Transaction`
  Commit the transaction associated with this connection. Normally, simply closing the connection will do, but more often committs may be needed. The business logic manager will close (and therefore commit) all transaction that it provides for usage.

  Specified by:
    `commit` in interface `Database`
  Specified by:
    `commit` in interface `Transaction`
  Specified by:
    `commit` in class `TransactionImplementation`

### rollback

    public void rollback()

  Description copied from interface: `Transaction`
  Rollback the transaction associated with this connection. Typically rollback should be doneif an error occurs in a business logic operation. The business logic manager will rollback a transaction that it provided for usage if it catches any exception during the business logic execution.

  Specified by:
    `rollback` in interface `Database`
  Specified by:
    `rollback` in interface `Transaction`
  Specified by:
    `rollback` in class `TransactionImplementation`

### lock

    public void lock(String symbol)

  Description copied from interface: `Transaction`
  Acquire a lock associated to the given application-specific symbol. This method will block as long as the lock is already taken on another Database object. The commit() and rollback() methods unlcok all locks acquired on this connection

  Specified by:
    `lock` in interface `Database`
  Specified by:
    `lock` in interface `Transaction`
  Overrides:
    `lock` in class `DBConnection`

### unlock

    public void unlock(String symbol)

  Description copied from interface: `Transaction`
  Free the lock on the given symbol, if any exists. This will allow the continuation of a thread that needs a lock on the same symbol and uses another Database object

  Specified by:
    `unlock` in interface `Database`
  Specified by:
    `unlock` in interface `Transaction`
  Overrides:
    `unlock` in class `DBConnection`

### close

    public void close()

  Description copied from interface: `Transaction`
  Give this connection back to the system. This will automatically commit the transaction if it was not committed. A connection cannot be used after closing.

  Specified by:
    `close` in interface `Database`
  Specified by:
    `close` in interface `Transaction`
  Specified by:
    `close` in class `TransactionImplementation`

### finalize

    protected void finalize()

  Overrides:
    `finalize` in class `Object`

### setContext

    public void setContext(Attributes a)

  Overrides:
    `setContext` in class `TransactionImplementation`

### getCreationStack

    public String getCreationStack()

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20