{"record":{"id":"9b531d887a3501b7","repo":"quarkusio/quarkus","slug":"incorrect-description-i1-getdescription","errorCode":null,"errorMessage":"Incorrect description: \" + i1.getDescription() + \", expected: \" + expectedDesc[0]","messagePattern":"Incorrect description: \" \\+ i1\\.getDescription\\(\\) \\+ \", expected: \" \\+ expectedDesc\\[0\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java","lineNumber":366,"sourceCode":"        });\n\n        assertRegionStats(expected, Item.class.getName());\n    }\n\n    private void verifyFindByIdItems(String[] expectedDesc, Counts expected) {\n        clearStatistics();\n\n        QuarkusTransaction.requiringNew().run(() -> {\n            findByIdItems(em, expectedDesc);\n        });\n\n        assertRegionStats(expected, Item.class.getName());\n    }\n\n    private static void findByIdItems(EntityManager em, String[] expectedDesc) {\n        final Item i1 = em.find(Item.class, 1L);\n        if (!i1.getDescription().equals(expectedDesc[0]))\n            throw new RuntimeException(\"Incorrect description: \" + i1.getDescription() + \", expected: \" + expectedDesc[0]);\n\n        final Item i2 = em.find(Item.class, 2L);\n        if (!i2.getDescription().equals(expectedDesc[1]))\n            throw new RuntimeException(\"Incorrect description: \" + i2.getDescription() + \", expected: \" + expectedDesc[1]);\n\n        final Item i3 = em.find(Item.class, 3L);\n        if (!i3.getDescription().equals(expectedDesc[2]))\n            throw new RuntimeException(\"Incorrect description: \" + i3.getDescription() + \", expected: \" + expectedDesc[2]);\n\n        List<Item> allitems = Arrays.asList(i1, i2, i3);\n        if (allitems.size() != 3) {\n            throw new RuntimeException(\"Incorrect number of results\");\n        }\n        StringBuilder sb = new StringBuilder(\"list of stored Items names:\\n\\t\");\n        for (Item p : allitems)\n            p.describeFully(sb);\n\n        sb.append(\"\\nList complete.\\n\");","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java#L348-L384","documentation":"Assertion inside findByIdItems for the first Item (id=1): after em.find(Item.class, 1L), the endpoint compares the item's description against expectedDesc[0] and throws this RuntimeException on mismatch. It validates that the read-only entity second-level cache serves the correct cached Item data.","triggerScenarios":"Verifying cached Items when the Item with id 1 in the cache (or database) has a description different from expectedDesc[0] — e.g. after the test updates descriptions and the cache still holds the old value, or seeding differs from expectations.","commonSituations":"Stale entity cache after a transactional update of descriptions; prior failed run left modified descriptions; read-write vs read-only cache strategy conflict; database reset not performed between runs.","solutions":["Evict the Item entity region before verification (sessionFactory.getCache().evict(Item.class))","Reset seed data so Item 1's description matches the expected value","Check the cache concurrency strategy matches the mutation pattern of the test","Clear statistics and cache between sub-tests"],"exampleFix":"// before\nfinal Item i1 = em.find(Item.class, 1L);\nif (!i1.getDescription().equals(expectedDesc[0])) throw ...\n// after\nsessionFactory.getCache().evict(Item.class);\nfinal Item i1 = em.find(Item.class, 1L);\nif (!i1.getDescription().equals(expectedDesc[0])) throw ...","handlingStrategy":"validation","validationCode":"sessionFactory.getCache().evict(Item.class);\nItem i1 = em.find(Item.class, 1L);\nif (i1 == null) throw new IllegalStateException(\"Item 1 not seeded\");","typeGuard":null,"tryCatchPattern":"try {\n    findByIdItems(em, expectedDesc);\n} catch (RuntimeException e) {\n    sessionFactory.getCache().evict(Item.class);\n    // reload; if it still fails, the DB data is wrong, not the cache\n}","preventionTips":["Evict entity regions before switching from update to verification phases","Reset DB to seed state between runs","Assert cache statistics alongside data to spot unexpected hits"],"tags":["hibernate","entity-cache","second-level-cache","test-assertion","quarkus"],"backgroundTag":"stale-cache-data","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"}