{"record":{"id":"23ce29a478ed2034","repo":"quarkusio/quarkus","slug":"incorrect-description-i2-getdescription","errorCode":null,"errorMessage":"Incorrect description: \" + i2.getDescription() + \", expected: \" + expectedDesc[1]","messagePattern":"Incorrect description: \" \\+ i2\\.getDescription\\(\\) \\+ \", expected: \" \\+ expectedDesc\\[1\\]","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":370,"sourceCode":"\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\");\n        System.out.print(sb);\n    }\n\n    private void testQuery() {","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java#L352-L388","documentation":"Same assertion pattern as error 3927 but for the second Item (id=2): em.find(Item.class, 2L) must return an Item whose description equals expectedDesc[1], otherwise this RuntimeException is thrown. It guards against the second-level cache serving incorrect cached entity state.","triggerScenarios":"Verifying cached Items when Item 2's cached or persisted description differs from expectedDesc[1], typically after a prior update step changed descriptions and the cache/database state is inconsistent with expectations.","commonSituations":"Stale entity cache following the test's update phase; Item 2 modified by a previous run; seed dataset mismatch; cache strategy (read-write) not evicting on update.","solutions":["Evict the Item entity region before verification","Reset the database to the seeded state before running the test","Verify expectedDesc[1] matches the seeded/updated description for Item 2","Inspect Item 2's actual stored description to determine if the DB or cache is stale"],"exampleFix":"// before\nfinal Item i2 = em.find(Item.class, 2L);\nif (!i2.getDescription().equals(expectedDesc[1])) throw ...\n// after\nsessionFactory.getCache().evict(Item.class);\nfinal Item i2 = em.find(Item.class, 2L);\nif (!i2.getDescription().equals(expectedDesc[1])) throw ...","handlingStrategy":"validation","validationCode":"sessionFactory.getCache().evict(Item.class);\nItem i2 = em.find(Item.class, 2L);\nif (i2 == null) throw new IllegalStateException(\"Item 2 not seeded\");","typeGuard":null,"tryCatchPattern":"try {\n    findByIdItems(em, expectedDesc);\n} catch (RuntimeException e) {\n    sessionFactory.getCache().evict(Item.class);\n    // reload to separate cache staleness from persistence issues\n}","preventionTips":["Verify expected descriptions come from the same constants used for seeding","Evict Item region after the update phase","Run each verification phase with a known cache state"],"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"}