{"record":{"id":"22ef82c69e377e36","repo":"quarkusio/quarkus","slug":"s-entities-do-not-support-being-attached-to-sever","errorCode":null,"errorMessage":"%s entities do not support being attached to several persistence units:\n\t- %s is attached to: %s","messagePattern":"(.+?) entities do not support being attached to several persistence units:\n\t- (.+?) is attached to: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/deployment/EntityToPersistenceUnitUtil.java","lineNumber":56,"sourceCode":"            if (!isCandidate) {\n                continue;\n            }\n\n            if (selectedPersistenceUnits.size() == 1) {\n                result.put(entityName, selectedPersistenceUnits.iterator().next());\n            } else {\n                violatingEntities.put(entityName, selectedPersistenceUnits);\n            }\n        }\n\n        if (violatingEntities.size() > 0) {\n            StringBuilder message = new StringBuilder(\n                    String.format(\"%s entities do not support being attached to several persistence units:\\n\", source));\n            for (Map.Entry<String, Set<String>> violatingEntityEntry : violatingEntities\n                    .entrySet()) {\n                message.append(\"\\t- \").append(violatingEntityEntry.getKey()).append(\" is attached to: \")\n                        .append(String.join(\",\", violatingEntityEntry.getValue()));\n                throw new IllegalStateException(message.toString());\n            }\n        }\n\n        return result;\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":63,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/deployment/EntityToPersistenceUnitUtil.java#L38-L63","documentation":"EntityToPersistenceUnitUtil.determineEntityPersistenceUnits validates at build time that each Panache (Reactive) entity maps to exactly one persistence unit. If an entity is found on several PUs, it throws IllegalStateException listing the entity and its PUs, because multi-PU entity attachment is unsupported.","triggerScenarios":"quarkus.hibernate-orm (reactive).persistence-units.<pu> scan-for-entities or explicit entity class lists including the same @Entity class in more than one persistence unit.","commonSituations":"Two named persistence units both configured to package-scan the same model package; copying entities into a shared package after splitting into multiple PUs; enabling 'scan-for-entities' on several PUs in one app.","solutions":["Configure each PU to scan/include only disjoint entity packages (quarkus.hibernate-orm.\"pu\".packages)","Remove duplicate entity inclusions from one of the persistence units","Give the shared entity to exactly one PU and reference others via their own entities"],"exampleFix":"// before\nquarkus.hibernate-orm.pu1.packages=org.acme.model\nquarkus.hibernate-orm.pu2.packages=org.acme.model\n// after\nquarkus.hibernate-orm.pu1.packages=org.acme.model.a\nquarkus.hibernate-orm.pu2.packages=org.acme.model.b","handlingStrategy":"validation","validationCode":"Set<String> pus = entitiesByPu().get(entityClass.getName());\nif (pus != null && pus.size() > 1)\n    throw new IllegalStateException(entityClass + \" attached to multiple persistence units: \" + pus);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep entity packages disjoint per persistence unit","Avoid enabling scan-for-entities broadly on multiple PUs","Review quarkus.hibernate-orm.\"pu\".packages config when splitting PUs"],"tags":["quarkus","hibernate-reactive","panache","persistence-unit","config"],"backgroundTag":"entity-multiple-persistence-units","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"}