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;
}
}
Aggregations