Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just in case if it so happens that you are getting this exception from inside a JUnit test you can transform the JUnit exception with a <code>TestRule</code> (this is was inspired by the source of <code>ExpectedException</code> <code>TestRule</code>)</p> <pre><code>public class HibernateBatchUnwindRule implements TestRule { private boolean handleAssumptionViolatedExceptions = false; private boolean handleAssertionErrors = false; private HibernateBatchUnwindRule() { } public static HibernateBatchUnwindRule create(){ return new HibernateBatchUnwindRule(); } public HibernateBatchUnwindRule handleAssertionErrors() { handleAssertionErrors = true; return this; } public HibernateBatchUnwindRule handleAssumptionViolatedExceptions() { handleAssumptionViolatedExceptions = true; return this; } public Statement apply(Statement base, org.junit.runner.Description description) { return new ExpectedExceptionStatement(base); } private class ExpectedExceptionStatement extends Statement { private final Statement fNext; public ExpectedExceptionStatement(Statement base) { fNext = base; } @Override public void evaluate() throws Throwable { try { fNext.evaluate(); } catch (AssumptionViolatedException e) { optionallyHandleException(e, handleAssumptionViolatedExceptions); } catch (AssertionError e) { optionallyHandleException(e, handleAssertionErrors); } catch (Throwable e) { handleException(e); } } } private void optionallyHandleException(Throwable e, boolean handleException) throws Throwable { if (handleException) { handleException(e); } else { throw e; } } private void handleException(Throwable e) throws Throwable { Throwable cause = e.getCause(); while (cause != null) { if (cause instanceof BatchUpdateException) { BatchUpdateException batchUpdateException = (BatchUpdateException) cause; throw batchUpdateException.getNextException(); } cause = cause.getCause(); }; throw e; } } </code></pre> <p>and then add the rule to the test case</p> <pre><code>public class SomeTest { @Rule public HibernateBatchUnwindRule batchUnwindRule = HibernateBatchUnwindRule.create(); @Test public void testSomething(){...} } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload