|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.triactive.jdo.store.mapping.Mapping
com.triactive.jdo.store.mapping.ColumnMapping
A database mapping that maps a Java type to a single column.
A ColumnMapping can set Java objects directly into JDBC PreparedStatement parameters, and get Java objects directly from JDBC ResultSet columns.
DatabaseAdapter.newColumnMapping(Class)
Field Summary | |
protected Column |
col
The column we are mapped to, or null for a prototypical
mapping. |
protected TypeInfo |
typeInfo
The JDBC type info. |
Fields inherited from class com.triactive.jdo.store.mapping.Mapping |
dba, fmd, type |
Constructor Summary | |
ColumnMapping(DatabaseAdapter dba,
java.lang.Class type)
Constructs a new column mapping for a given Java type. |
|
ColumnMapping(DatabaseAdapter dba,
FieldMetaData fmd)
Constructs a new column mapping for a given persistent field. |
Method Summary | |
SqlExpression |
accessAsFieldIn(FcoExpression objExpr)
Returns an SQL expression representing the persistent field mapped by this mapping within a particular first-class object expression. |
TypeInfo |
chooseColumnType(Column col)
Chooses an appropriate SQL type for a column based on the column's options. |
void |
defineConstraints(BaseTable table,
StoreManager.MgmtTransaction mtx)
Causes the mapping object to define whatever constraints it needs on its backing storage, relative to the specified table. Depending on the type of mapping, this may mean adding any or all of candidate keys, foreign keys, or indexes to the specified table and/or other tables.
This method only applies to base tables.
It will always be called after calling The StoreManager will never call this method more than once.. |
void |
defineStorage(Table table,
StoreManager.MgmtTransaction mtx)
Causes the mapping object to define whatever backing storage it needs, relative to the specified table. Depending on the type of mapping, this may mean adding columns to the table, constructing other related table objects, or both.
Storage in this case means only tables, columns, and primary keys.
Other candidate keys, foreign keys, and indexes are added by
The StoreManager will never call this method more than once.. |
boolean |
equals(java.lang.Object obj)
Tests this object for equality with another object. |
boolean |
getBoolean(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
byte |
getByte(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
char |
getChar(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
Column |
getColumn()
Returns the column this object is mapped to, if any. |
double |
getDouble(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
float |
getFloat(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
int |
getInt(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
long |
getLong(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
java.lang.Object |
getObject(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
short |
getShort(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
java.lang.String |
getSqlInsertionValue()
Returns the SQL text to be included in INSERT statements when inserting a value into this mapping's column. |
java.lang.String |
getSqlUpdateValue()
Returns the SQL text to be included in UPDATE statements when updating a value in this mapping's column. |
java.lang.String |
getString(PersistenceManager pm,
java.sql.ResultSet rs,
int column)
|
TypeInfo |
getTypeInfo()
Returns the actual SQL type used by this mapping. |
int |
hashCode()
Returns a hash code value for this object. |
void |
mapTo(Column col)
Links this mapping to a specific column. |
abstract SqlExpression |
newSqlExpression(QueryStatement.QueryColumn qsc)
Returns an SQL expression representing a reference to a column in a query statement. |
void |
setBoolean(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
boolean value)
|
void |
setByte(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
byte value)
|
void |
setChar(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
char value)
|
void |
setDouble(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
double value)
|
void |
setFloat(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
float value)
|
void |
setInt(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
int value)
|
void |
setLong(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
long value)
|
void |
setObject(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
java.lang.Object value)
|
void |
setShort(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
short value)
|
void |
setString(PersistenceManager pm,
java.sql.PreparedStatement ps,
int param,
java.lang.String value)
|
Methods inherited from class com.triactive.jdo.store.mapping.Mapping |
getDefaultMappingsByType, getFieldMetaData, getType, newSqlLiteral |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected TypeInfo typeInfo
protected Column col
null
for a prototypical
mapping.
Constructor Detail |
public ColumnMapping(DatabaseAdapter dba, java.lang.Class type)
dba
- the database adaptertype
- the Java class that this mapping maps to the databasepublic ColumnMapping(DatabaseAdapter dba, FieldMetaData fmd)
dba
- the database adapterfmd
- the field metadata for the field that this mapping maps to the
databaseMethod Detail |
public void defineStorage(Table table, StoreManager.MgmtTransaction mtx)
Storage in this case means only tables, columns, and primary keys.
Other candidate keys, foreign keys, and indexes are added by
Mapping.defineConstraints(com.triactive.jdo.store.sql.BaseTable, com.triactive.jdo.store.StoreManager.MgmtTransaction)
.
The StoreManager will never call this method more than once..
For this class, the mapping must be for a persistent field or an
exception is thrown.
A single column is defined in table whose type and options
are set according to the field metadata.
Once defined, mapTo(com.triactive.jdo.store.sql.Column)
is called to link this mapping to the new
column.
defineStorage
in class Mapping
table
- the table relative to which storage should be defined.mtx
- the context in which the mapping is being initializedpublic void defineConstraints(BaseTable table, StoreManager.MgmtTransaction mtx)
This method only applies to base tables.
It will always be called after calling Mapping.defineStorage(com.triactive.jdo.store.sql.Table, com.triactive.jdo.store.StoreManager.MgmtTransaction)
and is
passed the same table argument.
The StoreManager will never call this method more than once..
This method is a no-op for this class.
defineConstraints
in class Mapping
table
- the table relative to which constraints should be defined.mtx
- the context in which the mapping is being initializedpublic void mapTo(Column col)
Column.mapWith(com.triactive.jdo.store.mapping.ColumnMapping)
methodtypeInfo
to match the column'sThis method can be called at most once for a given mapping. Subclasses may do extra work as a consequence of mapping themselves to a column, but they should always call super.mapTo(col) first.
java.lang.IllegalStateException
- if this object is already mapped to a columnpublic TypeInfo chooseColumnType(Column col)
col
- the column
public final TypeInfo getTypeInfo()
public final Column getColumn()
null
if it's
not mapped to a specific column.public java.lang.String getSqlInsertionValue()
public java.lang.String getSqlUpdateValue()
public SqlExpression accessAsFieldIn(FcoExpression objExpr)
Mapping
accessAsFieldIn
in class Mapping
objExpr
- an expression representing a first-class objectpublic abstract SqlExpression newSqlExpression(QueryStatement.QueryColumn qsc)
qsc
- the query column referencepublic void setBoolean(PersistenceManager pm, java.sql.PreparedStatement ps, int param, boolean value)
public boolean getBoolean(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setChar(PersistenceManager pm, java.sql.PreparedStatement ps, int param, char value)
public char getChar(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setByte(PersistenceManager pm, java.sql.PreparedStatement ps, int param, byte value)
public byte getByte(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setShort(PersistenceManager pm, java.sql.PreparedStatement ps, int param, short value)
public short getShort(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setInt(PersistenceManager pm, java.sql.PreparedStatement ps, int param, int value)
public int getInt(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setLong(PersistenceManager pm, java.sql.PreparedStatement ps, int param, long value)
public long getLong(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setFloat(PersistenceManager pm, java.sql.PreparedStatement ps, int param, float value)
public float getFloat(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setDouble(PersistenceManager pm, java.sql.PreparedStatement ps, int param, double value)
public double getDouble(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setString(PersistenceManager pm, java.sql.PreparedStatement ps, int param, java.lang.String value)
public java.lang.String getString(PersistenceManager pm, java.sql.ResultSet rs, int column)
public void setObject(PersistenceManager pm, java.sql.PreparedStatement ps, int param, java.lang.Object value)
public java.lang.Object getObject(PersistenceManager pm, java.sql.ResultSet rs, int column)
public int hashCode()
hashCode
in class Mapping
public boolean equals(java.lang.Object obj)
equals
in class Mapping
obj
- the object to compare with
true
if the objects are equal,
false
otherwise.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |