Specialization of metadata for relational databases.
| Method from org.apache.openjpa.jdbc.meta.FieldMapping Detail: |
public void appendIsEmpty(SQLBuffer sql,
Select sel,
Joins joins) {
assertStrategy().appendIsEmpty(sql, sel, joins);
}
|
public void appendIsNotEmpty(SQLBuffer sql,
Select sel,
Joins joins) {
assertStrategy().appendIsNotEmpty(sql, sel, joins);
}
|
public void appendIsNotNull(SQLBuffer sql,
Select sel,
Joins joins) {
assertStrategy().appendIsNotNull(sql, sel, joins);
}
|
public void appendIsNull(SQLBuffer sql,
Select sel,
Joins joins) {
assertStrategy().appendIsNull(sql, sel, joins);
}
|
public void appendSize(SQLBuffer sql,
Select sel,
Joins joins) {
assertStrategy().appendSize(sql, sel, joins);
}
|
public void clearMapping() {
_strategy = null;
_fk = null;
_unq = null;
_idx = null;
_outer = false;
_orderCol.setColumn(null);
_val.clearMapping();
_key.clearMapping();
_elem.clearMapping();
_info.clear();
setResolve(MODE_MAPPING, false);
}
Clear mapping information, including strategy. |
public void copy(FieldMetaData fmd) {
super.copy(fmd);
if (_fetchMode == Integer.MAX_VALUE)
_fetchMode = ((FieldMapping) fmd).getEagerFetchMode();
}
|
public void copyMappingInfo(FieldMapping fm) {
setMappedBy(fm.getMappedBy());
_info.copy(fm.getMappingInfo());
_val.copyMappingInfo(fm.getValueMapping());
_key.copyMappingInfo(fm.getKeyMapping());
_elem.copyMappingInfo(fm.getElementMapping());
}
Copy mapping info from the given instance to this one. |
public void copyMappingInfo(ValueMapping vm) {
_val.copyMappingInfo(vm);
}
|
public void customDelete(OpenJPAStateManager sm,
JDBCStore store) throws SQLException {
assertStrategy().customDelete(sm, store);
}
|
public void customInsert(OpenJPAStateManager sm,
JDBCStore store) throws SQLException {
assertStrategy().customInsert(sm, store);
}
|
public void customUpdate(OpenJPAStateManager sm,
JDBCStore store) throws SQLException {
assertStrategy().customUpdate(sm, store);
}
|
public void delete(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm) throws SQLException {
assertStrategy().delete(sm, store, rm);
}
|
public void deleteRow(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm) throws SQLException {
if (_fk != null) {
Row row = rm.getRow(getTable(), Row.ACTION_DELETE, sm, true);
row.whereForeignKey(_fk, sm);
}
}
Delete the row for this object if the reference foreign key exists.
Utility method for use by mapping strategies. |
public String getAlias() {
return assertStrategy().getAlias();
}
|
public ColumnIO getColumnIO() {
return _val.getColumnIO();
}
|
public Column[] getColumns() {
// pcl: 6 July 2007: this seems a bit hacky, but if the mapping is a
// version, it will have a NoneFieldMapping (since the version strategy
// for the class takes care of it's mapping), and NoneFieldStrategies
// do not have columns.
if (isVersion())
return getDeclaringMapping().getVersion().getColumns();
else
return _val.getColumns();
}
|
public ClassMapping getDeclaredTypeMapping() {
return _val.getDeclaredTypeMapping();
}
|
public ClassMapping getDeclaringMapping() {
return (ClassMapping) getDeclaringMetaData();
}
|
public ClassMapping getDefiningMapping() {
return (ClassMapping) getDefiningMetaData();
}
|
public int getEagerFetchMode() {
if (_fetchMode == Integer.MAX_VALUE)
_fetchMode = FetchConfiguration.DEFAULT;
return _fetchMode;
}
|
public ValueMapping getElementMapping() {
return _elem;
}
|
public ClassMapping getEmbeddedMapping() {
return _val.getEmbeddedMapping();
}
|
public FieldMapping getFieldMapping() {
return this;
}
|
public ForeignKey getForeignKey() {
return _val.getForeignKey();
}
|
public ForeignKey getForeignKey(ClassMapping target) {
return _val.getForeignKey(target);
}
|
public ValueHandler getHandler() {
return _val.getHandler();
}
|
public ClassMapping[] getIndependentTypeMappings() {
return _val.getIndependentTypeMappings();
}
|
public FieldMapping[] getInverseMappings() {
return (FieldMapping[]) getInverseMetaDatas();
}
|
public ColumnIO getJoinColumnIO() {
return (_io == null) ? ColumnIO.UNRESTRICTED : _io;
}
I/O information on the join columns. |
public int getJoinDirection() {
return _val.getJoinDirection();
}
|
public ForeignKey getJoinForeignKey() {
return _fk;
}
Foreign key linking the field table to the class' primary table. |
public Index getJoinIndex() {
return _idx;
}
Index on join foreign key columns. |
public Unique getJoinUnique() {
return _unq;
}
Unique constraint on join foreign key columns. |
public ValueMapping getKeyMapping() {
return _key;
}
|
public FieldMapping getMappedByMapping() {
return (FieldMapping) getMappedByMetaData();
}
|
public FieldMappingInfo getMappingInfo() {
return _info;
}
Raw mapping data about field's join to parent table, as well as
miscellaneous specialized columns like order column. |
public MappingRepository getMappingRepository() {
return (MappingRepository) getRepository();
}
|
public Column getOrderColumn() {
return _orderCol.getColumn();
}
Field order column, if any. |
public ColumnIO getOrderColumnIO() {
return _orderCol.getColumnIO();
}
I/O information for order column. |
public int getPolymorphic() {
return _val.getPolymorphic();
}
|
public Row getRow(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm,
int action) throws SQLException {
Row row = null;
boolean newOuterRow = false;
if (_fk != null && _outer && action != Row.ACTION_DELETE) {
// if updating with outer join, delete old value first, then insert;
// we can't just update b/c the row might not exist
if (action == Row.ACTION_UPDATE) {
// maybe some other field already is updating?
row = rm.getRow(getTable(), Row.ACTION_UPDATE, sm, false);
if (row == null) {
Row del = rm.getRow(getTable(), Row.ACTION_DELETE, sm,
true);
del.whereForeignKey(_fk, sm);
}
} else
row = rm.getRow(getTable(), Row.ACTION_INSERT, sm, false);
// only update/insert if the row exists already or the value is
// not null/default
if (row == null && !isNullValue(sm)) {
row = rm.getRow(getTable(), Row.ACTION_INSERT, sm, true);
newOuterRow = true;
}
} else
row = rm.getRow(getTable(), action, sm, true);
// setup fk
if (row != null && _fk != null) {
if (row.getAction() == Row.ACTION_INSERT)
row.setForeignKey(_fk, _io, sm);
else
row.whereForeignKey(_fk, sm);
// if this is a new outer joined row, mark it invalid until
// some mapping actually sets information on it
if (newOuterRow)
row.setValid(false);
}
return row;
}
Return the row to use for this field. This method is meant only for
single-value fields that might reside in a table that is joined to
the primary table through the join foreign key. It is not
meant for multi-valued fields like collections and maps. The method
checks whether we're using an outer join and if so it deletes the
field's previous value, then if the field is non-null returns an insert
row for the new value. The join foreign key will already be set on
the returned row; mapping strategies just need to set their own values.
Utility method for use by mapping strategies. |
public int getSelectSubclasses() {
return _val.getSelectSubclasses();
}
|
public FieldStrategy getStrategy() {
return _strategy;
}
The strategy used to map this mapping. |
public Table getTable() {
if (_fk != null)
return _fk.getTable();
if (_val.getForeignKey() != null)
return _val.getForeignKey().getTable();
return getDefiningMapping().getTable();
}
The mapping's primary table. |
public ClassMapping getTypeMapping() {
return _val.getTypeMapping();
}
|
public boolean getUseClassCriteria() {
return _val.getUseClassCriteria();
}
|
public Index getValueIndex() {
return _val.getValueIndex();
}
|
public ValueMappingInfo getValueInfo() {
return _val.getValueInfo();
}
|
public FieldMapping getValueMappedByMapping() {
return _val.getValueMappedByMapping();
}
|
public ValueMapping getValueMapping() {
return (ValueMapping) getValue();
}
|
public Unique getValueUnique() {
return _val.getValueUnique();
}
|
public void initialize() {
assertStrategy().initialize();
}
|
public void insert(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm) throws SQLException {
assertStrategy().insert(sm, store, rm);
}
|
public Boolean isCustomDelete(OpenJPAStateManager sm,
JDBCStore store) {
return assertStrategy().isCustomDelete(sm, store);
}
|
public Boolean isCustomInsert(OpenJPAStateManager sm,
JDBCStore store) {
return assertStrategy().isCustomInsert(sm, store);
}
|
public Boolean isCustomUpdate(OpenJPAStateManager sm,
JDBCStore store) {
return assertStrategy().isCustomUpdate(sm, store);
}
|
public boolean isEagerSelectToMany() {
return assertStrategy().isEagerSelectToMany();
}
|
public boolean isJoinOuter() {
return _outer;
}
Whether to use an outer join from the class' primary table. |
public boolean isMapped() {
return _strategy != NoneFieldStrategy.getInstance();
}
Returns true if field class does not use the "none" strategy (including
if it has a null strategy, and therefore is probably in the process of
being mapped). |
public boolean isVersionable() {
return assertStrategy().isVersionable();
}
|
public Joins join(Select sel) {
if (_fk == null)
return null;
Joins joins = sel.newJoins();
if (_outer)
return joins.outerJoin(_fk, true, false);
return joins.join(_fk, true, false);
}
Return any joins needed to get from the primary table to this table. |
public Joins join(Joins joins,
boolean forceOuter) {
return assertStrategy().join(joins, forceOuter);
}
|
public Joins join(Joins joins,
boolean forceOuter,
boolean toMany) {
if (_fk == null)
return joins;
if (_outer || forceOuter)
return joins.outerJoin(_fk, true, toMany);
return joins.join(_fk, true, toMany);
}
Joins from the owning class' table to the table where this field lies
using the join foreign key. Utility method for use by mapping strategies. |
public Joins joinKey(Joins joins,
boolean forceOuter) {
return assertStrategy().joinKey(joins, forceOuter);
}
|
public Joins joinKeyRelation(Joins joins,
boolean forceOuter,
boolean traverse) {
return assertStrategy().joinKeyRelation(joins, forceOuter, traverse);
}
|
public Joins joinRelation(Joins joins,
boolean forceOuter,
boolean traverse) {
return assertStrategy().joinRelation(joins, forceOuter, traverse);
}
|
public void load(OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch) throws SQLException {
assertStrategy().load(sm, store, fetch);
}
|
public void load(OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch,
Result res) throws SQLException {
assertStrategy().load(sm, store, fetch, res);
}
|
public void loadEagerJoin(OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch,
Result res) throws SQLException {
assertStrategy().loadEagerJoin(sm, store, fetch, res);
}
|
public Object loadEagerParallel(OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch,
Object res) throws SQLException {
return assertStrategy().loadEagerParallel(sm, store, fetch, res);
}
|
public Object loadKeyProjection(JDBCStore store,
JDBCFetchConfiguration fetch,
Result res,
Joins joins) throws SQLException {
return assertStrategy()
.loadKeyProjection(store, fetch, res, joins);
}
|
public Object loadProjection(JDBCStore store,
JDBCFetchConfiguration fetch,
Result res,
Joins joins) throws SQLException {
return assertStrategy().loadProjection(store, fetch, res, joins);
}
|
public void map(boolean adapt) {
assertStrategy().map(adapt);
}
|
public void mapConstraints(String name,
boolean adapt) {
_val.mapConstraints(name, adapt);
}
|
public void mapJoin(boolean adapt,
boolean joinRequired) {
Table table = _info.getTable(this, joinRequired, adapt);
if(table != null && table.equals(getDefiningMapping().getTable())) {
// Don't create a join if the field's table is the same as the
// class's table.
table = null;
}
ForeignKey join = null;
if (table != null)
join = _info.getJoin(this, table, adapt);
if (join == null && joinRequired)
throw new MetaDataException(_loc.get("join-required", this));
if (join == null) {
_info.assertNoJoin(this, true);
_info.assertNoForeignKey(this, !adapt);
_info.assertNoUnique(this, !adapt);
_info.assertNoIndex(this, !adapt);
} else {
_fk = join;
_io = _info.getColumnIO();
_outer = _info.isJoinOuter();
_unq = _info.getJoinUnique(this, false, adapt);
_idx = _info.getJoinIndex(this, adapt);
}
}
Map this field to its table, optionally requiring that it be
in another table. Utility method for use by mapping strategies. |
public void mapPrimaryKey(boolean adapt) {
if (adapt && _fk != null && _fk.getTable().getPrimaryKey() == null)
getMappingRepository().getMappingDefaults().
installPrimaryKey(this, _fk.getTable());
}
Maps the primary key on the secondary table for this field, if the
user's defaults create one. This must be called after
this field is mapped so that it's table has its columns set. |
public void orderLocal(Select sel,
ClassMapping elem,
Joins joins) {
_orderCol.order(sel, elem, joins);
JDBCOrder[] orders = (JDBCOrder[]) getOrders();
for (int i = 0; i < orders.length; i++)
if (!orders[i].isInRelation())
orders[i].order(sel, elem, joins);
}
Add ordering to the given select for all non-relation order values,
including the synthetic order column, if any. |
public void orderRelation(Select sel,
ClassMapping elem,
Joins joins) {
JDBCOrder[] orders = (JDBCOrder[]) getOrders();
for (int i = 0; i < orders.length; i++)
if (orders[i].isInRelation())
orders[i].order(sel, elem, joins);
}
Add ordering to the given select for all relation-based values. |
public void refSchemaComponents() {
if (_fk != null) {
_fk.ref();
_fk.refColumns();
}
if (_orderCol.getColumn() != null)
_orderCol.getColumn().ref();
_val.refSchemaComponents();
_key.refSchemaComponents();
_elem.refSchemaComponents();
}
Increment the reference count of used schema components. |
public boolean resolve(int mode) {
int cur = getResolve();
if (super.resolve(mode))
return true;
if ((mode & MODE_MAPPING) != 0 && (cur & MODE_MAPPING) == 0)
resolveMapping();
if ((mode & MODE_MAPPING_INIT) != 0 && (cur & MODE_MAPPING_INIT) == 0)
initializeMapping();
return false;
}
|
public int select(Select sel,
OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch,
int eagerMode) {
return assertStrategy().select(sel, sm, store, fetch, eagerMode);
}
|
public void selectEagerJoin(Select sel,
OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch,
int eagerMode) {
assertStrategy().selectEagerJoin(sel, sm, store, fetch, eagerMode);
}
|
public void selectEagerParallel(SelectExecutor sel,
OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch,
int eagerMode) {
assertStrategy().selectEagerParallel(sel, sm, store, fetch, eagerMode);
}
|
public void setColumnIO(ColumnIO io) {
_val.setColumnIO(io);
}
|
public void setColumns(Column[] cols) {
_val.setColumns(cols);
}
|
public void setEagerFetchMode(int mode) {
_fetchMode = mode;
}
|
public void setFieldMapping(FieldMapping owner) {
assertStrategy().setFieldMapping(owner);
}
|
public void setForeignKey(ForeignKey fk) {
_val.setForeignKey(fk);
}
|
public void setForeignKey(Row row,
OpenJPAStateManager sm) throws SQLException {
_val.setForeignKey(row, sm);
}
|
public void setHandler(ValueHandler handler) {
_val.setHandler(handler);
}
|
public void setJoinColumnIO(ColumnIO io) {
_io = io;
}
I/O information on the join columns. |
public void setJoinDirection(int direction) {
_val.setJoinDirection(direction);
}
|
public void setJoinForeignKey(ForeignKey fk) {
_fk = fk;
}
Foreign key linking the field table to the class' primary table. |
public void setJoinIndex(Index idx) {
_idx = idx;
}
Index on join foreign key columns. |
public void setJoinOuter(boolean outer) {
_outer = outer;
}
Whether to use an outer join from the class' primary table. |
public void setJoinUnique(Unique unq) {
_unq = unq;
}
Unique constraint on join foreign key columns. |
public void setOrderColumn(Column order) {
_orderCol.setColumn(order);
}
Field order column, if any. |
public void setOrderColumnIO(ColumnIO io) {
_orderCol.setColumnIO(io);
}
I/O information for order column. |
public void setPolymorphic(int poly) {
_val.setPolymorphic(poly);
}
|
public void setStrategy(FieldStrategy strategy,
Boolean adapt) {
// set strategy first so we can access it during mapping
FieldStrategy orig = _strategy;
_strategy = strategy;
if (strategy != null) {
try {
strategy.setFieldMapping(this);
if (adapt != null)
strategy.map(adapt.booleanValue());
} catch (RuntimeException re) {
// reset strategy
_strategy = orig;
throw re;
}
// if set to unmapped, clear defined field cache in parent
if (!isMapped())
getDefiningMapping().clearDefinedFieldCache();
}
}
The strategy used to map this mapping. The adapt
parameter determines whether to adapt when mapping the strategy;
use null if the strategy should not be mapped. |
public void setUseClassCriteria(boolean criteria) {
_val.setUseClassCriteria(criteria);
}
|
public void setValueIndex(Index idx) {
_val.setValueIndex(idx);
}
|
public void setValueUnique(Unique unq) {
_val.setValueUnique(unq);
}
|
public int supportsSelect(Select sel,
int type,
OpenJPAStateManager sm,
JDBCStore store,
JDBCFetchConfiguration fetch) {
return assertStrategy().supportsSelect(sel, type, sm, store, fetch);
}
|
public void syncMappingInfo() {
if (isVersion()) {
// we rely on the fact that the version will setup our mapping
// info correctly when it is synced
} else if (getMappedByMapping() != null) {
_info.clear();
_val.getValueInfo().clear();
_key.getValueInfo().clear();
_elem.getValueInfo().clear();
FieldMapping mapped = getMappedByMapping();
_info.syncStrategy(this);
if (_orderCol.getColumn() != null
&& mapped.getOrderColumn() == null)
_info.syncOrderColumn(this);
_val.getValueInfo().setUseClassCriteria
(_val.getUseClassCriteria());
_key.getValueInfo().setUseClassCriteria
(_key.getUseClassCriteria());
_elem.getValueInfo().setUseClassCriteria
(_elem.getUseClassCriteria());
} else {
_info.syncWith(this);
_val.syncMappingInfo();
_key.syncMappingInfo();
_elem.syncMappingInfo();
}
}
Update MappingInfo with our current mapping information. |
public Object toDataStoreValue(Object val,
JDBCStore store) {
return assertStrategy().toDataStoreValue(val, store);
}
|
public Object toKeyDataStoreValue(Object val,
JDBCStore store) {
return assertStrategy().toKeyDataStoreValue(val, store);
}
|
public void update(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm) throws SQLException {
assertStrategy().update(sm, store, rm);
}
|
protected boolean validateDataStoreExtensionPrefix(String prefix) {
return "jdbc-".equals(prefix);
}
|
public void where(OpenJPAStateManager sm,
JDBCStore store,
RowManager rm,
Object prevValue) throws SQLException {
assertStrategy().where(sm, store, rm, prevValue);
}
|
public void whereForeignKey(Row row,
OpenJPAStateManager sm) throws SQLException {
_val.whereForeignKey(row, sm);
}
|
public void wherePrimaryKey(Select sel,
OpenJPAStateManager sm,
JDBCStore store) {
if (_fk != null)
sel.whereForeignKey(_fk, sm.getObjectId(), getDefiningMapping(),
store);
else
sel.wherePrimaryKey(sm.getObjectId(), getDefiningMapping(),
store);
}
Add a wherePrimaryKey or whereForeignKey
condition to the given select, depending on whether we have a join
foreign key. |