Search in sources :

Example 1 with RecoverableException

use of org.hibernate.cfg.RecoverableException in project hibernate-orm by hibernate.

the class InFlightMetadataCollectorImpl method processEndOfQueue.

private void processEndOfQueue(List<FkSecondPass> endOfQueueFkSecondPasses) {
    /*
		 * If a second pass raises a recoverableException, queue it for next round
		 * stop of no pass has to be processed or if the number of pass to processes
		 * does not diminish between two rounds.
		 * If some failing pass remain, raise the original exception
		 */
    boolean stopProcess = false;
    RuntimeException originalException = null;
    while (!stopProcess) {
        List<FkSecondPass> failingSecondPasses = new ArrayList<FkSecondPass>();
        for (FkSecondPass pass : endOfQueueFkSecondPasses) {
            try {
                pass.doSecondPass(getEntityBindingMap());
            } catch (RecoverableException e) {
                failingSecondPasses.add(pass);
                if (originalException == null) {
                    originalException = (RuntimeException) e.getCause();
                }
            }
        }
        stopProcess = failingSecondPasses.size() == 0 || failingSecondPasses.size() == endOfQueueFkSecondPasses.size();
        endOfQueueFkSecondPasses = failingSecondPasses;
    }
    if (endOfQueueFkSecondPasses.size() > 0) {
        throw originalException;
    }
}
Also used : FkSecondPass(org.hibernate.cfg.FkSecondPass) ArrayList(java.util.ArrayList) RecoverableException(org.hibernate.cfg.RecoverableException)

Aggregations

ArrayList (java.util.ArrayList)1 FkSecondPass (org.hibernate.cfg.FkSecondPass)1 RecoverableException (org.hibernate.cfg.RecoverableException)1