_log.debug("Inserted deferred bean "+buildIdentityFromPKs(waitingObjTable, waitingObj.getObject())); }
addBean(finishedObj); if (_log.isDebugEnabled()) { Table waitingObjTable = ((SqlDynaClass)finishedObj.getDynaClass()).getTable();  _log.debug("Inserted deferred bean "+buildIdentityFromPKs(waitingObjTable, finishedObj));
    public void addBean(DynaBean bean) throws DataSinkException    {        Table table = _model.getDynaClassFor(bean).getTable();        if (!table.getForeignKeys().isEmpty())        {            WaitingObject waitingObj = new WaitingObject(bean);            for (Iterator fkIt = table.getForeignKeys().iterator(); fkIt.hasNext();)            {                ForeignKey fk         = (ForeignKey)fkIt.next();                Identity   fkIdentity = buildIdentityFromFK(table, fk, bean);                if (fkIdentity != null)                {                    HashSet identitiesForTable = (HashSet)_processedIdentities.get(fk.getForeignTable());                        if (!identitiesForTable.contains(fkIdentity))                    {                        waitingObj.addPendingFK(fkIdentity);                    }                }            }            if (waitingObj.hasPendingFKs())            {                if (_log.isDebugEnabled())                {                    StringBuffer msg = new StringBuffer();                    msg.append("Defering insertion of bean ");                    msg.append(buildIdentityFromPKs(table, bean).toString());                    msg.append(" because it is waiting for:");                    for (Iterator it = waitingObj.getPendingFKs(); it.hasNext();)                    {                        msg.append("\n  ");                        msg.append(it.next().toString());                    }                    _log.debug(msg.toString());                }                _waitingObjects.add(waitingObj);                return;            }        }                try        {            _platform.insert(_model, bean, _connection);            if (!_connection.getAutoCommit())            {                _connection.commit();            }            if (_log.isDebugEnabled())            {                _log.debug("Inserted bean "+buildIdentityFromPKs(table, bean).toString());            }        }        catch (Exception ex)        {            if (_haltOnErrors)            {                _platform.returnConnection(_connection);                throw new DataSinkException(ex);            }            else            {                _log.debug("Exception while inserting a bean into the database", ex);            }        }        if (_processedIdentities.containsKey(table.getName()))        {            Identity identity           = buildIdentityFromPKs(table, bean);            HashSet  identitiesForTable = (HashSet)_processedIdentities.get(table.getName());            identitiesForTable.add(identity);            for (Iterator waitingObjIt = _waitingObjects.iterator(); waitingObjIt.hasNext();)            {                WaitingObject waitingObj = (WaitingObject)waitingObjIt.next();                Identity      fkIdentity = waitingObj.removePendingFK(identity);                if (!waitingObj.hasPendingFKs())                {                    waitingObjIt.remove();                    // the object was only waiting for this one, so store it now                    // prior to that we also update the fk fields in case one of the pk                    // columns of the target object is auto-incremented by the database                    updateFKColumns(waitingObj.getObject(), bean, fkIdentity.getForeignKeyName());                    addBean(waitingObj.getObject());                    if (_log.isDebugEnabled())                    {                        Table waitingObjTable = ((SqlDynaClass)waitingObj.getObject().getDynaClass()).getTable();                        _log.debug("Inserted deferred bean "+buildIdentityFromPKs(waitingObjTable, waitingObj.getObject()));                    }                }            }        }    }