{"record":{"id":"9513099457abed42","repo":"quarkusio/quarkus","slug":"stored-xml-element-not-found","errorCode":null,"errorMessage":"Stored XML element not found!","messagePattern":"Stored XML element not found!","errorType":"http","errorClass":"IllegalStateException","httpStatus":500,"severity":"error","filePath":"integration-tests/jpa-postgresql-withxml/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java","lineNumber":148,"sourceCode":"\n    @GET\n    @Path(\"datasource-xml\")\n    public String datasourceXml() throws SQLException, TransformerException {\n        try (final Connection con = ds.getConnection()) {\n            deleteXmlSchema(con);\n            createXmlSchema(con);\n            writeXmlObject(con);\n            checkWrittenXmlObject(con);\n        }\n        return \"OK\";\n    }\n\n    private void checkWrittenXmlObject(Connection con) throws SQLException {\n        try (Statement stmt = con.createStatement()) {\n            final ResultSet resultSet = stmt.executeQuery(\"SELECT val FROM xmltest\");\n            final boolean next = resultSet.next();\n            if (!next) {\n                throw new IllegalStateException(\"Stored XML element not found!\");\n            }\n            final String storedValue = resultSet.getString(1);\n            if (storedValue == null) {\n                throw new IllegalStateException(\"Stored XML element was loaded as null!\");\n            }\n            String expectedMatch = \"<?xml version=\\\"1.0\\\" standalone=\\\"no\\\"?><root><ele>1</ele><ele>2</ele></root>\";\n            if (!expectedMatch.equals(storedValue)) {\n                throw new IllegalStateException(\"Stored XML element is not matching expected value of '\" + expectedMatch\n                        + \"', but was '\" + storedValue + \"'\");\n            }\n        }\n    }\n\n    private void writeXmlObject(Connection con) throws SQLException, TransformerException {\n        TransformerFactory factory = TransformerFactory.newInstance();\n        final String _xmlDocument = \"<root><ele>1</ele><ele>2</ele></root>\";\n        Transformer identityTransformer = factory.newTransformer();\n        try (PreparedStatement ps = con.prepareStatement(\"INSERT INTO xmltest VALUES (?,?)\")) {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/jpa-postgresql-withxml/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java#L130-L166","documentation":"An IllegalStateException from the XML integration test's direct JDBC check that a row exists in the xmltest table. The SELECT 'SELECT val FROM xmltest' returned no rows, meaning the earlier writeXmlObject step did not persist anything or wrote to a different table/database.","triggerScenarios":"checkWrittenXmlObject(Connection) runs resultSet.next() on the xmltest query and gets false - the INSERT in writeXmlObject never committed or the table is empty at check time.","commonSituations":"Transaction isolation/commit ordering issues between write and check connections, wrong datasource checked, or a prior test step that deleted the row.","solutions":["Ensure writeXmlObject commits before checkWrittenXmlObject runs (same transaction or committed connection)","Verify both methods use the same datasource/connection to the same database","Check the INSERT in writeXmlObject actually executed (look for swallowed SQLExceptions)"],"exampleFix":"// before\ntry (Statement stmt = con.createStatement()) {\n    final ResultSet rs = stmt.executeQuery(\"SELECT val FROM xmltest\");\n    if (!rs.next()) { throw new IllegalStateException(\"Stored XML element not found!\"); }\n// after\ntry (Statement stmt = con.createStatement()) {\n    final ResultSet rs = stmt.executeQuery(\"SELECT val FROM xmltest ORDER BY 1 LIMIT 1\");\n    assertTrue(rs.next(), \"xmltest table empty - did the write transaction commit?\");","handlingStrategy":"validation","validationCode":"try (Statement s = con.createStatement();\n     ResultSet rs = s.executeQuery(\"SELECT count(*) FROM xmltest\")) {\n    rs.next();\n    boolean tableHasData = rs.getInt(1) > 0;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit the write connection before checking with another statement","Use the same connection/transaction for write and read checks in tests","Fail fast: assert INSERT affected 1 row in writeXmlObject"],"tags":["jdbc","postgresql","xml","test-assertion"],"backgroundTag":"expected-row-missing","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}