_log.warn("Exception while inserting a bean into the database", ex);
_log.debug("Exception while inserting a bean into the database", ex);
    public void addBean(DynaBean bean) throws DataSinkException    {        Table table = _dynaSql.getSqlDynaClass(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(fk, bean);                HashSet    identitiesForTable = (HashSet)_processedIdentities.get(fk.getForeignTable());                if (!identitiesForTable.contains(fkIdentity))                {                    waitingObj.addPendingFK(fkIdentity);                }            }            if (waitingObj.hasPendingFKs())            {                _waitingObjects.add(waitingObj);                return;            }        }                try        {            _dynaSql.insert(bean, _connection);            if (!_connection.getAutoCommit())            {                _connection.commit();            }        }        catch (SQLException ex)        {            if (_haltOnErrors)            {                _dynaSql.returnConnection(_connection);                throw new DataSinkException(ex);            }            else            {                _log.warn("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());                }            }        }    }