Primary table row that tracks foreign keys and auto-inc columns.
| Method from org.apache.openjpa.jdbc.sql.PrimaryRow Detail: |
public void clearForeignKey(ForeignKey fk) throws SQLException {
super.clearForeignKey(fk);
if (_fkSet != null)
_fkSet[fk.getIndex()] = null;
if (_fkIO != null)
_fkIO[fk.getIndex()] = null;
}
|
public void clearRelationId(Column col) throws SQLException {
super.clearRelationId(col);
if (_relSet != null) {
int idx = getRelationIdIndex(col);
_relSet[idx] = null;
_callbacks[idx] = null;
}
}
|
public void copyInto(RowImpl row,
boolean whereOnly) {
super.copyInto(row, whereOnly);
if (!(row instanceof PrimaryRow))
return;
PrimaryRow prow = (PrimaryRow) row;
prow._pk = _pk;
prow._pkIO = _pkIO;
if ((flags & PK_WHERE) > 0)
prow.flags |= PK_WHERE;
if (!whereOnly && (flags & PK_SET) > 0)
prow.flags |= PK_SET;
if (_fkWhere != null) {
if (prow._fkWhere == null)
prow._fkWhere = new OpenJPAStateManager[_fkWhere.length];
System.arraycopy(_fkWhere, 0, prow._fkWhere, 0, _fkWhere.length);
}
if (!whereOnly && _fkSet != null) {
if (prow._fkSet == null)
prow._fkSet = new OpenJPAStateManager[_fkSet.length];
System.arraycopy(_fkSet, 0, prow._fkSet, 0, _fkSet.length);
if (_fkIO != null) {
if (prow._fkIO == null)
prow._fkIO = new ColumnIO[_fkIO.length];
System.arraycopy(_fkIO, 0, prow._fkIO, 0, _fkIO.length);
}
}
if (!whereOnly && _relSet != null) {
if (prow._relSet == null) {
prow._relSet = new OpenJPAStateManager[_relSet.length];
prow._callbacks = new RelationId[_callbacks.length];
}
System.arraycopy(_relSet, 0, prow._relSet, 0, _relSet.length);
System.arraycopy(_callbacks, 0, prow._callbacks, 0,
_callbacks.length);
}
}
|
protected String generateSQL(DBDictionary dict) {
try {
if ((flags & PK_SET) > 0)
super.setPrimaryKey(_pkIO, _pk);
if ((flags & PK_WHERE) > 0)
super.wherePrimaryKey(_pk);
if (_fkSet != null) {
ForeignKey[] fks = getTable().getForeignKeys();
ColumnIO io;
for (int i = 0; i < _fkSet.length; i++) {
if (_fkSet[i] != null) {
io = (_fkIO == null) ? null : _fkIO[i];
super.setForeignKey(fks[i], io, _fkSet[i]);
}
}
}
if (_relSet != null) {
Column[] cols = getTable().getRelationIdColumns();
for (int i = 0; i < _relSet.length; i++)
if (_relSet[i] != null)
super.setRelationId(cols[i], _relSet[i], _callbacks[i]);
}
if (_fkWhere != null) {
ForeignKey[] fks = getTable().getForeignKeys();
for (int i = 0; i < _fkWhere.length; i++)
if (_fkWhere[i] != null)
super.whereForeignKey(fks[i], _fkWhere[i]);
}
}
catch (SQLException se) {
throw SQLExceptions.getStore(se, dict);
}
return super.generateSQL(dict);
}
|
public Object getFailedObject() {
return _failed;
}
|
public ColumnIO getForeignKeyIO(ForeignKey fk) {
return (_fkIO == null) ? null : _fkIO[fk.getIndex()];
}
Return the I/O information for the given set foreign key. |
public OpenJPAStateManager getForeignKeySet(ForeignKey fk) {
return (_fkSet == null) ? null : _fkSet[fk.getIndex()];
}
Return the value for the given foreign key. Values not needed for
constraint analyses are not recorded. |
public OpenJPAStateManager getForeignKeyWhere(ForeignKey fk) {
return (_fkWhere == null) ? null : _fkWhere[fk.getIndex()];
}
Return the value for the given foreign key. Values not needed for
constraint analyses are not recorded. |
public int getIndex() {
return _idx;
}
The index of this row in ordered row list. |
public OpenJPAStateManager getPrimaryKey() {
return _pk;
}
|
public RelationId getRelationIdCallback(Column col) {
return (_callbacks == null) ? null
: _callbacks[getRelationIdIndex(col)];
}
Return the recorded callbacks for the given relation id column. Only
values that are dependent on a new, unflushed auto-assigned instance
are recorded. |
public OpenJPAStateManager getRelationIdSet(Column col) {
return (_relSet == null) ? null : _relSet[getRelationIdIndex(col)];
}
Return the recorded value for the given relation id column. Only
values that are dependent on a new, unflushed auto-assigned instance
are recorded. |
public boolean isDependent() {
return (flags & DEPENDENT) > 0;
}
Mark this row as dependent on some other row. |
protected RowImpl newInstance(Column[] cols,
int action) {
return new PrimaryRow(cols, action, _pk);
}
|
public void setDependent(boolean dependent) {
if (dependent)
flags |= DEPENDENT;
else
flags &= ~DEPENDENT;
}
Mark this row as dependent on some other row. |
public void setFailedObject(Object failed) {
_failed = failed;
}
|
public void setForeignKey(ForeignKey fk,
OpenJPAStateManager sm) throws SQLException {
setForeignKey(fk, null, sm);
}
|
public void setForeignKey(ForeignKey fk,
ColumnIO io,
OpenJPAStateManager sm) throws SQLException {
if (!delayForeignKey(fk, sm, true))
super.setForeignKey(fk, io, sm);
else
recordForeignKey(fk, io, sm, true);
}
|
public void setIndex(int idx) {
_idx = idx;
}
The index of this row in ordered row list. |
protected void setObject(Column col,
Object val,
int metaType,
boolean overrideDefault) throws SQLException {
// make sure we're not setting two different values
Object prev = getSet(col);
if (prev != null) {
if (prev == NULL)
prev = null;
if (!rowValueEquals(prev, val)) {
throw new InvalidStateException(_loc.get("diff-values",
new Object[]{ col.getFullName(),
(prev == null) ? null : prev.getClass(), prev,
(val == null) ? null : val.getClass(), val })).
setFatal(true);
}
}
super.setObject(col, val, metaType, overrideDefault);
}
|
public void setPrimaryKey(OpenJPAStateManager sm) throws SQLException {
setPrimaryKey(null, sm);
}
|
public void setPrimaryKey(ColumnIO io,
OpenJPAStateManager sm) {
_pk = sm;
flags |= PK_SET;
_pkIO = io;
// force valid
setValid(true);
}
|
public void setRelationId(Column col,
OpenJPAStateManager sm,
RelationId rel) throws SQLException {
if (sm == null || sm.getObjectId() != null || !sm.isNew()
|| sm.isFlushed() || !isPrimaryKeyAutoAssigned(sm))
super.setRelationId(col, sm, rel);
else {
if (_relSet == null) {
Column[] cols = getTable().getRelationIdColumns();
_relSet = new OpenJPAStateManager[cols.length];
_callbacks = new RelationId[cols.length];
}
int idx = getRelationIdIndex(col);
_relSet[idx] = sm;
_callbacks[idx] = rel;
}
}
|
public void whereForeignKey(ForeignKey fk,
OpenJPAStateManager sm) throws SQLException {
if (!delayForeignKey(fk, sm, false))
super.whereForeignKey(fk, sm);
else
recordForeignKey(fk, null, sm, false);
}
|
public void wherePrimaryKey(OpenJPAStateManager sm) throws SQLException {
_pk = sm;
flags |= PK_WHERE;
// force valid
if (getAction() == ACTION_DELETE)
setValid(true);
}
|