de.mathema.pride
Class ObjectAdapter

java.lang.Object
  extended by de.mathema.pride.DatabaseAdapter
      extended by de.mathema.pride.ObjectAdapter
Direct Known Subclasses:
MappedObject, ValueObjectAdapter

public abstract class ObjectAdapter
extends DatabaseAdapter

Convenience baseclass, providing a set of ready-to-use standard methods for interaction between the database and data entity objects. This is a derivation from DatabaseAdapter assuming that derived types provide functions to access the type's record descriptor, primary key definition and operation value object

Author:
Jan Lessner

Field Summary
static java.lang.String REVISION_ID
           
 
Constructor Summary
ObjectAdapter()
           
 
Method Summary
 void commit()
           
 java.lang.String constraint()
          Returns a constraint made up from the primary key attributes of this getEntity()
 java.lang.String constraint(java.lang.String[] dbfields)
           
 java.lang.String constraint(java.lang.String[] dbfields, boolean byLike)
           
 int create()
           
 int create(java.lang.String[] autoFields)
           
 void createx()
           
 int delete()
           
 int delete(java.lang.String[] dbkeyfields)
           
 void fetch(java.lang.Object key)
          Fetch an object by key.
 void fetchx()
           
 void fetchx(java.lang.String attrName)
           
 void fetchx(java.lang.String[] attrNames)
           
 void find()
          Same like query() but takes the first record only
 void find(java.lang.String where)
          Same like query() but takes the first record only
 void find(java.lang.String[] dbfields)
          Same like query() but takes the first record only
 java.lang.String[] getAutoFields()
          Returns a list of fields being managed automatically by the database and therefore must not be passed in a record creation.
protected static Database getDatabase(ExtensionDescriptor xd)
           
protected static Database getDatabase(RecordDescriptor red)
           
protected abstract  RecordDescriptor getDescriptor()
          Returns the entity's record desriptor.
protected abstract  java.lang.Object getEntity()
          Returns the value object the adapter is operating on
 java.lang.String[] getKeyFields()
          Returns the primary key fields for this entity.
protected  ExtensionDescriptor getXDescriptor()
          Returns the attribute extension descriptor for this entity.
 void process(java.lang.Exception x)
           
 ResultIterator query(java.lang.String where)
          Fetch an object by a self-made where clause
 ResultIterator query(java.lang.String[] dbfields)
          Fetch an object by fields.
 ResultIterator queryAll()
          Fetch all objects
 int update()
           
 int update(java.lang.String where)
           
 int update(java.lang.String[] dbkeyfields)
           
 int update(java.lang.String[] dbkeyfields, java.lang.String[] updatefields)
           
 int update(java.lang.String where, java.lang.String[] updatefields)
           
 void updatex()
           
 void updatex(java.lang.String attrName)
           
 void updatex(java.lang.String[] attrNames)
           
 ResultIterator wildcard(java.lang.String[] dbfields)
          Same like query() but performs a wildcard search
 
Methods inherited from class de.mathema.pride.DatabaseAdapter
commit, constraint, create, create, create, delete, delete, fetch, fetch, fetch, fetch, find, find, find, process, query, query, queryAll, update, update, update, update, update, update, update, update, wildcard
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION_ID

public static final java.lang.String REVISION_ID
See Also:
Constant Field Values
Constructor Detail

ObjectAdapter

public ObjectAdapter()
Method Detail

getDescriptor

protected abstract RecordDescriptor getDescriptor()
Returns the entity's record desriptor. This function is used by the the public database access functions below to provide simplified standard functionality. This function is abstract and must therefore be provided by every derived type.


getKeyFields

public java.lang.String[] getKeyFields()
Returns the primary key fields for this entity. This function returns null by default causing the update() and delete() functions below to use the first field in the record descriptor as primary key.


getAutoFields

public java.lang.String[] getAutoFields()
Returns a list of fields being managed automatically by the database and therefore must not be passed in a record creation. This function returns null by default causing all fields of the record descriptor to be considered.


getXDescriptor

protected ExtensionDescriptor getXDescriptor()
Returns the attribute extension descriptor for this entity. The function returns null by default, causing the extension access functions to fail. So be shure to override this function if you're using extended attributes.


getEntity

protected abstract java.lang.Object getEntity()
Returns the value object the adapter is operating on


getDatabase

protected static Database getDatabase(RecordDescriptor red)

getDatabase

protected static Database getDatabase(ExtensionDescriptor xd)

fetch

public void fetch(java.lang.Object key)
           throws java.sql.SQLException
Fetch an object by key.

Throws:
java.sql.SQLException

query

public ResultIterator query(java.lang.String[] dbfields)
                     throws java.sql.SQLException
Fetch an object by fields. The values are taken from the fields' accociated get-methods

Throws:
java.sql.SQLException

wildcard

public ResultIterator wildcard(java.lang.String[] dbfields)
                        throws java.sql.SQLException
Same like query() but performs a wildcard search

Throws:
java.sql.SQLException

find

public void find(java.lang.String[] dbfields)
          throws java.sql.SQLException
Same like query() but takes the first record only

Throws:
java.sql.SQLException

find

public void find()
          throws java.sql.SQLException
Same like query() but takes the first record only

Throws:
java.sql.SQLException

queryAll

public ResultIterator queryAll()
                        throws java.sql.SQLException
Fetch all objects

Throws:
java.sql.SQLException

query

public ResultIterator query(java.lang.String where)
                     throws java.sql.SQLException
Fetch an object by a self-made where clause

Throws:
java.sql.SQLException

find

public void find(java.lang.String where)
          throws java.sql.SQLException
Same like query() but takes the first record only

Throws:
java.sql.SQLException

update

public int update()
           throws java.sql.SQLException
Throws:
java.sql.SQLException

update

public int update(java.lang.String[] dbkeyfields)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

update

public int update(java.lang.String[] dbkeyfields,
                  java.lang.String[] updatefields)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

update

public int update(java.lang.String where)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

update

public int update(java.lang.String where,
                  java.lang.String[] updatefields)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

create

public int create()
           throws java.sql.SQLException
Throws:
java.sql.SQLException

create

public int create(java.lang.String[] autoFields)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

delete

public int delete()
           throws java.sql.SQLException
Throws:
java.sql.SQLException

delete

public int delete(java.lang.String[] dbkeyfields)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

constraint

public java.lang.String constraint(java.lang.String[] dbfields,
                                   boolean byLike)

constraint

public java.lang.String constraint(java.lang.String[] dbfields)

constraint

public java.lang.String constraint()
Returns a constraint made up from the primary key attributes of this getEntity()


commit

public void commit()
            throws java.sql.SQLException
Throws:
java.sql.SQLException

process

public void process(java.lang.Exception x)
             throws java.sql.SQLException
Throws:
java.sql.SQLException

updatex

public void updatex()
             throws java.sql.SQLException
Throws:
java.sql.SQLException

updatex

public void updatex(java.lang.String attrName)
             throws java.sql.SQLException
Throws:
java.sql.SQLException

updatex

public void updatex(java.lang.String[] attrNames)
             throws java.sql.SQLException
Throws:
java.sql.SQLException

fetchx

public void fetchx()
            throws java.sql.SQLException
Throws:
java.sql.SQLException

fetchx

public void fetchx(java.lang.String attrName)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

fetchx

public void fetchx(java.lang.String[] attrNames)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

createx

public void createx()
             throws java.sql.SQLException
Throws:
java.sql.SQLException