|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.mathema.pride.RecordDescriptor
public class RecordDescriptor
A RecordDescriptor defines the mapping of relation database records to JAVA objects
Nested Class Summary | |
---|---|
static interface |
RecordDescriptor.ExtractionMode
Defined constants for the ResultSet extraction mode of this descriptor and its depending AttributeDescriptor s. |
Field Summary | |
---|---|
protected de.mathema.pride.AttributeDescriptor[] |
attrDescriptors
|
protected RecordDescriptor |
baseDescriptor
|
protected java.lang.String |
dbContext
|
protected java.lang.String |
dbtable
|
protected java.lang.Class |
objectType
|
static java.lang.String |
REVISION_ID
|
Constructor Summary | |
---|---|
RecordDescriptor(java.lang.Class objectType,
java.lang.String dbtable,
RecordDescriptor baseDescriptor,
java.lang.String[][] attributeMap)
Creates a new mapping descriptor like constructor above but always uses the current DB context of DatabaseFactory
and auto extraction mode. |
|
RecordDescriptor(java.lang.Class objectType,
java.lang.String dbtable,
RecordDescriptor baseDescriptor,
java.lang.String[][] attributeMap,
int extractionMode)
Creates a new mapping descriptor like constructor above but always uses the current DB context of DatabaseFactory . |
|
RecordDescriptor(java.lang.Class objectType,
java.lang.String dbContext,
java.lang.String dbtable,
RecordDescriptor baseDescriptor,
java.lang.String[][] attributeMap)
|
|
RecordDescriptor(java.lang.Class objectType,
java.lang.String dbContext,
java.lang.String dbtable,
RecordDescriptor baseDescriptor,
java.lang.String[][] attributeMap,
int extractionMode)
Creates a new mapping descriptor |
|
RecordDescriptor(RecordDescriptor red,
java.lang.String alias)
Like copy constructor above but without alternate table name |
|
RecordDescriptor(RecordDescriptor red,
java.lang.String alias,
java.lang.String altTable)
Copy constructor |
Method Summary | |
---|---|
java.lang.String |
getConstraint(java.lang.Object obj,
java.lang.String[] dbfields,
boolean byLike,
Database db)
Constructs a constraint for a database query |
int |
getConstraint(java.lang.Object obj,
java.lang.String[] dbfields,
PreparedOperation pop,
java.lang.String table,
int position)
Similar to function above but instead writes the values into a passed PreparedOperation . |
java.lang.String |
getContext()
|
java.lang.String |
getCreationValues(java.lang.Object obj,
java.lang.String[] excludeAttrs,
Database db)
Returns a comma-seperated list of all attribute values of the passed object as required for an SQL insert operation |
int |
getCreationValues(java.lang.Object obj,
java.lang.String[] excludeAttrs,
PreparedOperation pop,
java.lang.String table,
int position)
Similar to function above but instead writes the values into a passed PreparedOperation . |
java.lang.String |
getFieldNames(java.lang.String[] excludeAttrs)
Returns a comma-seperated list of all attribute names as required for an SQL insert operation |
java.lang.Class |
getObjectType()
|
java.lang.Object |
getPrimaryKey(java.lang.Object obj)
Get the passed object's primary key value, assuming that this is the value of the very first attribute mapping. |
java.lang.String |
getPrimaryKeyField()
Get the name of the database field making up the primary key. |
protected java.lang.String |
getResultFields()
Returns the list of fields to be looked up in a query, which is by default the list of all fields registered in this descriptor and its base descriptors and thus the same list as returned by getFieldNames(java.lang.String[]) . |
java.lang.String |
getTableName()
|
java.lang.String |
getUpdateValues(java.lang.Object obj,
Database db)
Returns a database update clause for the passed object's attribute. |
java.lang.String |
getUpdateValues(java.lang.Object obj,
java.lang.String[] excludeAttrs,
java.lang.String[] includeAttrs,
Database db)
Like the function above except that all attributes listed in excludeAttrs
are left off instead of the first one. |
int |
getUpdateValues(java.lang.Object obj,
java.lang.String[] excludeAttrs,
java.lang.String[] includeAttrs,
PreparedOperation pop,
java.lang.String table,
int position)
Similar to function above but instead writes the values into a passed PreparedOperation . |
java.lang.Object |
getWhereValue(java.lang.Object obj,
java.lang.String dbfield,
boolean byLike,
Database db)
Runs getWhereValue on the attribute descriptor, representing the attribute specified by parameter dbfield |
void |
getWhereValue(java.lang.Object obj,
java.lang.String dbfield,
PreparedOperation pop,
java.lang.String table,
int position)
Similar to function above but instead writes the value into a passed PreparedOperation . |
int |
record2object(java.lang.Object obj,
java.sql.ResultSet results,
int position)
Extract result values from a result set according to the field mappings The extraction is by default performed in auto-mode. i.e. first by-name if possible and by-index otherwise. |
int |
record2object(java.lang.Object obj,
java.sql.ResultSet results,
int position,
de.mathema.pride.AttributeDescriptor attrDesc)
|
int |
record2object(java.lang.Object obj,
java.sql.ResultSet results,
int position,
java.lang.String[] includeAttrs)
Function used to inject auto-generated field values after an insertion operation. |
int |
totalAttributes()
Returns the total number of attributes being mapped by this descriptor and all of its base descriptors. |
protected java.lang.String |
trim(java.lang.String value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Class objectType
protected java.lang.String dbContext
protected java.lang.String dbtable
protected de.mathema.pride.AttributeDescriptor[] attrDescriptors
protected RecordDescriptor baseDescriptor
public static final java.lang.String REVISION_ID
Constructor Detail |
---|
public RecordDescriptor(java.lang.Class objectType, java.lang.String dbContext, java.lang.String dbtable, RecordDescriptor baseDescriptor, java.lang.String[][] attributeMap, int extractionMode) throws IllegalDescriptorException
objectType
- JAVA object type being mapped by the descriptordbtable
- Database table to refer toattributeMap
- Description of field mappings used to instantiate
AttributeDescriptor
s. Each inner array is passed as parameter
attrInfo
to the constructor of AttributeDescriptor
.extractionMode
- The ResultSet extraction mode according to the constants
defined in interface RecordDescriptor.ExtractionMode
.
IllegalDescriptorException
public RecordDescriptor(java.lang.Class objectType, java.lang.String dbtable, RecordDescriptor baseDescriptor, java.lang.String[][] attributeMap) throws IllegalDescriptorException
DatabaseFactory
and auto extraction mode.
IllegalDescriptorException
public RecordDescriptor(java.lang.Class objectType, java.lang.String dbtable, RecordDescriptor baseDescriptor, java.lang.String[][] attributeMap, int extractionMode) throws IllegalDescriptorException
DatabaseFactory
.
IllegalDescriptorException
public RecordDescriptor(java.lang.Class objectType, java.lang.String dbContext, java.lang.String dbtable, RecordDescriptor baseDescriptor, java.lang.String[][] attributeMap) throws IllegalDescriptorException
IllegalDescriptorException
public RecordDescriptor(RecordDescriptor red, java.lang.String alias, java.lang.String altTable)
red
- The descriptor which to copy data fromalias
- An optional alias name to use for database access.
This is of interest if this descriptor is supposed to be used
in an aggregation of multiple descriptors for accessing full
table joins. May be null;altTable
- An optional alternative table name to use for database
access. If both alias and table name are specified, the alias is
not applied to the alternate table name.public RecordDescriptor(RecordDescriptor red, java.lang.String alias)
Method Detail |
---|
public int totalAttributes()
public java.lang.String getTableName()
public java.lang.Class getObjectType()
public java.lang.String getContext()
public java.lang.String getPrimaryKeyField()
public int record2object(java.lang.Object obj, java.sql.ResultSet results, int position, de.mathema.pride.AttributeDescriptor attrDesc) throws java.sql.SQLException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.sql.SQLException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public int record2object(java.lang.Object obj, java.sql.ResultSet results, int position) throws java.sql.SQLException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
obj
- The objet where to transfer the data toresults
- The result set to extract the data fromposition
- The start index for data extraction
AttributeDescriptor
for details).
java.sql.SQLException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public int record2object(java.lang.Object obj, java.sql.ResultSet results, int position, java.lang.String[] includeAttrs) throws java.sql.SQLException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
obj
- The objet where to transfer the data toresults
- The result set to extract the data fromincludeAttrs
- An array of attribute names to consider
java.sql.SQLException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public java.lang.Object getPrimaryKey(java.lang.Object obj) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public java.lang.Object getWhereValue(java.lang.Object obj, java.lang.String dbfield, boolean byLike, Database db) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
dbfield
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public void getWhereValue(java.lang.Object obj, java.lang.String dbfield, PreparedOperation pop, java.lang.String table, int position) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.sql.SQLException
PreparedOperation
.
obj
- the value object from which to take the value fromdbfield
- the field to fetch the value forpop
- the PreparedOperation
to pass the value totable
- the name of the database table, the operation refers to.
See AttributeDescriptor
for the nasty reasonposition
- index of the prepared statements next parameter to set
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.sql.SQLException
public java.lang.String getConstraint(java.lang.Object obj, java.lang.String[] dbfields, boolean byLike, Database db) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
dbfields
- the database fields for which to take a
constraint value from the passed value object. If this is null,
the first registered attribute is used.obj
- the value object from which to take the constraint valuesbyLike
- if false
, builds the constraint from equality
checks, otherwise by using operator like
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public int getConstraint(java.lang.Object obj, java.lang.String[] dbfields, PreparedOperation pop, java.lang.String table, int position) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.sql.SQLException
PreparedOperation
.
obj
- the value object from which to take the constraint valuesdbfields
- the database fields for which to take a
constraint value from the passed value object. If this is null,
the first registered attribute is used.pop
- the PreparedOperation
to pass the value totable
- the name of the database table, the operation refers to.
See AttributeDescriptor
for the nasty reasonposition
- index of the prepared statements next parameter to set
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.sql.SQLException
protected java.lang.String trim(java.lang.String value)
public java.lang.String getUpdateValues(java.lang.Object obj, Database db) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public java.lang.String getUpdateValues(java.lang.Object obj, java.lang.String[] excludeAttrs, java.lang.String[] includeAttrs, Database db) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
excludeAttrs
are left off instead of the first one.
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public int getUpdateValues(java.lang.Object obj, java.lang.String[] excludeAttrs, java.lang.String[] includeAttrs, PreparedOperation pop, java.lang.String table, int position) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.sql.SQLException
PreparedOperation
.
obj
- the value object from which to take the data fromexcludeAttrs
- an array of field names which are to be ignored.pop
- the PreparedOperation
to pass the value totable
- the name of the database table, the operation refers to.
See AttributeDescriptor
for the nasty reasonposition
- index of the prepared statements next parameter to set
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.sql.SQLException
public java.lang.String getCreationValues(java.lang.Object obj, java.lang.String[] excludeAttrs, Database db) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public int getCreationValues(java.lang.Object obj, java.lang.String[] excludeAttrs, PreparedOperation pop, java.lang.String table, int position) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.sql.SQLException
PreparedOperation
.
obj
- the value object from which to take the creation valuespop
- the PreparedOperation
to pass the value totable
- the name of the database table, the operation refers to.
See AttributeDescriptor
for the nasty reasonposition
- index of the prepared statements next parameter to set
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.sql.SQLException
public java.lang.String getFieldNames(java.lang.String[] excludeAttrs)
protected java.lang.String getResultFields()
getFieldNames(java.lang.String[])
.
Overriding this function must be done with great care. The extraction
of data from a result set in record2object(java.lang.Object, java.sql.ResultSet, int, de.mathema.pride.AttributeDescriptor)
is performed by index and relies on the number and order of
fields defined by this function. If it returns '*' for example, make
shure to call AttributeDescriptor.record2object(java.sql.ResultSet, int)
with index -1
to force data extraction by name.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |