implementation.
| Method from org.apache.openjpa.jdbc.meta.ValueMappingImpl Detail: |
public void clearMapping() {
_handler = null;
_cols = Schemas.EMPTY_COLUMNS;
_unq = null;
_idx = null;
_fk = null;
_join = JOIN_FORWARD;
_info.clear();
setResolve(MODE_MAPPING | MODE_MAPPING_INIT, false);
}
|
public void copyMappingInfo(ValueMapping vm) {
setValueMappedBy(vm.getValueMappedBy());
setPolymorphic(vm.getPolymorphic());
_info.copy(vm.getValueInfo());
ClassMapping embed = vm.getEmbeddedMapping();
if (embed != null && getEmbeddedMapping() != null) {
FieldMapping[] tmplates = embed.getFieldMappings();
FieldMapping[] fms = getEmbeddedMapping().getFieldMappings();
if (tmplates.length == fms.length)
for (int i = 0; i < fms.length; i++)
fms[i].copyMappingInfo(tmplates[i]);
}
}
|
public ColumnIO getColumnIO() {
if (_cols.length == 0 && _fk == null && getValueMappedBy() != null)
return getValueMappedByMapping().getColumnIO();
return (_io == null) ? ColumnIO.UNRESTRICTED : _io;
}
|
public Column[] getColumns() {
if (_cols.length != 0)
return _cols;
if (_fk != null)
return _fk.getColumns();
if (getValueMappedBy() != null)
return getValueMappedByMapping().getColumns();
return _cols;
}
|
public ClassMapping getDeclaredTypeMapping() {
return (ClassMapping) getDeclaredTypeMetaData();
}
|
public ClassMapping getEmbeddedMapping() {
return (ClassMapping) getEmbeddedMetaData();
}
|
public FieldMapping getFieldMapping() {
return (FieldMapping) getFieldMetaData();
}
|
public ForeignKey getForeignKey() {
if (_fk == null && getValueMappedBy() != null)
return getValueMappedByMapping().getForeignKey();
return _fk;
}
|
public ForeignKey getForeignKey(ClassMapping target) {
if (_fk == null && getValueMappedBy() != null)
return getValueMappedByMapping().getForeignKey(target);
if (target == null)
return _fk;
if (_fk == null && _cols.length == 0)
return null;
// always use least-derived joinable type
for (ClassMapping sup = target; sup != null;
sup = sup.getJoinablePCSuperclassMapping()) {
if (sup == getTypeMetaData())
return _fk;
target = sup;
}
synchronized (this) {
if (_targetFKs != null) {
Object cachedFK = _targetFKs.get(target);
if (cachedFK != null)
return (ForeignKey) cachedFK;
} else
_targetFKs = new HashMap();
ForeignKey newfk = (_join == JOIN_FORWARD)
? newForwardForeignKey(target) : newInverseForeignKey(target);
_targetFKs.put(target, newfk);
return newfk;
}
}
|
public ValueHandler getHandler() {
return _handler;
}
|
public ClassMapping[] getIndependentTypeMappings() {
ClassMapping rel = getTypeMapping();
if (rel == null)
return ClassMapping.EMPTY_MAPPINGS;
if (_poly != POLY_TRUE) {
if (!rel.isMapped())
return ClassMapping.EMPTY_MAPPINGS;
if (_typeArr == null)
_typeArr = new ClassMapping[]{ rel };
return _typeArr;
}
return rel.getIndependentAssignableMappings();
}
|
public int getJoinDirection() {
if (_fk == null && getValueMappedBy() != null)
return getValueMappedByMapping().getJoinDirection();
return _join;
}
|
public MappingRepository getMappingRepository() {
return (MappingRepository) getRepository();
}
|
public int getPolymorphic() {
return _poly;
}
|
public int getSelectSubclasses() {
ClassMapping rel = getTypeMapping();
if (rel == null || !rel.isMapped())
return -1;
switch (_poly) {
case POLY_FALSE:
return (_criteria) ? Select.SUBS_NONE : Select.SUBS_EXACT;
case POLY_TRUE:
ClassMapping[] assign = rel.getIndependentAssignableMappings();
if (assign.length != 1 || assign[0] != rel)
return -1;
// no break
case POLY_JOINABLE:
return (_criteria) ? Select.SUBS_JOINABLE
: Select.SUBS_ANY_JOINABLE;
default:
throw new InternalException();
}
}
|
public ClassMapping getTypeMapping() {
return (ClassMapping) getTypeMetaData();
}
|
public boolean getUseClassCriteria() {
if (_fk == null && getValueMappedBy() != null)
return getValueMappedByMapping().getUseClassCriteria();
return _criteria;
}
|
public Index getValueIndex() {
return _idx;
}
|
public ValueMappingInfo getValueInfo() {
return _info;
}
|
public FieldMapping getValueMappedByMapping() {
return (FieldMapping) getValueMappedByMetaData();
}
|
public Unique getValueUnique() {
return _unq;
}
|
public void mapConstraints(String name,
boolean adapt) {
_unq = _info.getUnique(this, name, adapt);
_idx = _info.getIndex(this, name, adapt);
}
|
public void refSchemaComponents() {
for (int i = 0; i < _cols.length; i++)
_cols[i].ref();
if (_fk != null) {
_fk.ref();
_fk.refColumns();
}
ClassMapping embed = getEmbeddedMapping();
if (embed != null)
embed.refSchemaComponents();
}
|
public boolean resolve(int mode) {
int cur = getResolve();
if (super.resolve(mode))
return true;
ClassMapping embed = getEmbeddedMapping();
if (embed != null)
embed.resolve(mode);
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 void setColumnIO(ColumnIO io) {
_io = io;
}
|
public void setColumns(Column[] cols) {
if (cols == null)
cols = Schemas.EMPTY_COLUMNS;
_cols = cols;
}
|
public void setForeignKey(ForeignKey fk) {
_fk = fk;
if (fk == null)
_join = JOIN_FORWARD;
}
|
public void setForeignKey(Row row,
OpenJPAStateManager rel) throws SQLException {
if (rel != null)
row.setForeignKey(getForeignKey((ClassMapping) rel.getMetaData()),
_io, rel);
else if (_fk != null)
row.setForeignKey(_fk, _io, null);
else {
for (int i = 0; i < _cols.length; i++) {
if (_io == null || (row.getAction() == Row.ACTION_INSERT
&& _io.isInsertable(i, true))
|| (row.getAction() != Row.ACTION_INSERT
&& _io.isUpdatable(i, true)))
row.setNull(_cols[i]);
}
}
}
|
public void setHandler(ValueHandler handler) {
_handler = handler;
}
|
public void setJoinDirection(int direction) {
_join = direction;
}
|
public void setPolymorphic(int poly) {
_poly = poly;
}
|
public void setUseClassCriteria(boolean criteria) {
_criteria = criteria;
}
|
public void setValueIndex(Index idx) {
_idx = idx;
}
|
public void setValueUnique(Unique unq) {
_unq = unq;
}
|
public void syncMappingInfo() {
if (getValueMappedBy() != null)
_info.clear();
else {
_info.syncWith(this);
ClassMapping embed = getEmbeddedMapping();
if (embed != null)
embed.syncMappingInfo();
}
}
|
public void whereForeignKey(Row row,
OpenJPAStateManager rel) throws SQLException {
if (rel != null)
row.whereForeignKey(getForeignKey((ClassMapping)
rel.getMetaData()), rel);
else if (_fk != null)
row.whereForeignKey(_fk, null);
else
for (int i = 0; i < _cols.length; i++)
row.whereNull(_cols[i]);
}
|