package com.mysema.query.suites;

import static com.mysema.query.sql.domain.QSurvey.survey;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import com.google.common.base.Throwables;
import com.mysema.query.AbstractBaseTest;
import com.mysema.query.Connections;
import com.mysema.query.JavaSpecVersion;
import com.mysema.query.QueryException;
import com.mysema.query.sql.H2Templates;

import org.junit.BeforeClass;
import org.junit.Test;

public class H2ExceptionSuiteTest extends AbstractBaseTest {

    @BeforeClass
    public static void setUp() throws Exception {
        Connections.initH2();
        Connections.setTemplates(H2Templates.builder().build());

        Connections.getConnection().createStatement()
                .execute("ALTER TABLE SURVEY ADD CONSTRAINT UNIQUE_ID UNIQUE(ID)");
    }

    public static void tearDown() throws Exception {
        Connections.getConnection().createStatement()
                .execute("ALTER TABLE SURVEY DROP CONSTRAINT UNIQUE_ID");
    }

    @Test
    public void UpdateBatchFailed() {
        execute(insert(survey).columns(survey.name, survey.name2)
                .values("New Survey", "New Survey"));
        Exception result = null;
        try {
            execute(update(survey)
                    .set(survey.id, 1).addBatch()
                    .set(survey.id, 2).addBatch());
        } catch (QueryException e) {
            result = e;
        }
        assertNotNull(result);
        String stackTraceAsString = Throwables.getStackTraceAsString(result);
        switch (JavaSpecVersion.CURRENT) {
            case JAVA6:
                assertTrue(stackTraceAsString
                        .contains("Detailed SQLException information:"));
                break;
            default://Java™ 7 and higher
                assertTrue(stackTraceAsString
                        .contains("Suppressed:"));
        }
    }
}

@@ -175,16 +175,47 @@
 tTrue;%0A%0A
+import java.sql.SQLException;%0A%0A
 import c
@@ -436,27 +436,138 @@
 ery.sql.
-H2Templates
+DefaultSQLExceptionTranslator;%0Aimport com.mysema.query.sql.H2Templates;%0Aimport com.mysema.query.sql.SQLExceptionTranslator
 ;%0A%0Aimpor
@@ -677,16 +677,126 @@
 Test %7B%0A%0A
+    private static final SQLExceptionTranslator exceptionTranslator = DefaultSQLExceptionTranslator.DEFAULT;%0A%0A
     @Bef
@@ -1279,24 +1279,516 @@
 D%22);%0A    %7D%0A%0A
+    @Test%0A    public void SQLExceptionCreationTranslated() %7B%0A        SQLException e1 = new SQLException(%22Exception #1%22, %2242001%22, 181);%0A        SQLException e2 = new SQLException(%22Exception #2%22, %22HY000%22, 1030);%0A        e1.setNextException(e2);%0A        SQLException sqlException = new SQLException(%22Batch operation failed%22);%0A        sqlException.setNextException(e1);%0A        RuntimeException result = exceptionTranslator.translate(sqlException);%0A        inspectExceptionResult(result);%0A    %7D%0A%0A
     @Test%0A  
@@ -2221,32 +2221,139 @@
 otNull(result);%0A
+        inspectExceptionResult(result);%0A    %7D%0A%0A    private void inspectExceptionResult(Exception result) %7B%0A
         String s

Add the simple exception creation case to the ExceptionSuiteTest