{"record":{"id":"82cc886c904a8c23","repo":"hibernate/hibernate-orm","slug":"no-audit-mapping-available-for-s","errorCode":null,"errorMessage":"No audit mapping available for %s","messagePattern":"No audit mapping available for (.+?)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/EntityAuditSupport.java","lineNumber":122,"sourceCode":"\n\tprivate final EntityPersister entityPersister;\n\tprivate final SessionFactoryImplementor factory;\n\tprivate final AuditMapping auditMapping;\n\tprivate final EntityTableMapping[] auditTableMappings;\n\tprivate final boolean[] auditedPropertyMask;\n\tprivate final boolean useServerTransactionTimestamps;\n\tprivate final String currentTimestampFunctionName;\n\tprivate final MutationGroup staticAuditInsertMutationGroup;\n\tprivate final MutationGroup transactionEndUpdateMutationGroup;\n\n\tpublic EntityAuditSupport(\n\t\t\tEntityPersister entityPersister,\n\t\t\tSessionFactoryImplementor factory) {\n\t\tthis.entityPersister = entityPersister;\n\t\tthis.factory = factory;\n\t\tthis.auditMapping = entityPersister.getAuditMapping();\n\t\tif ( auditMapping == null ) {\n\t\t\tthrow new MappingException( \"No audit mapping available for \" + entityPersister.getEntityName() );\n\t\t}\n\t\tthis.auditTableMappings = buildAuditTableMappings();\n\t\tthis.auditedPropertyMask = new boolean[entityPersister.getPropertySpan()];\n\t\tfor ( int i = 0; i < auditedPropertyMask.length; i++ ) {\n\t\t\tauditedPropertyMask[i] = !entityPersister.isPropertyAuditedExcluded( i );\n\t\t}\n\t\tthis.useServerTransactionTimestamps =\n\t\t\t\tfactory.getChangesetCoordinator().useServerTimestamp( factory.getJdbcServices().getDialect() );\n\t\tthis.currentTimestampFunctionName = useServerTransactionTimestamps\n\t\t\t\t? factory.getJdbcServices().getDialect().currentTimestamp()\n\t\t\t\t: null;\n\t\tthis.staticAuditInsertMutationGroup = entityPersister.isDynamicInsert()\n\t\t\t\t? null\n\t\t\t\t: buildAuditInsertMutationGroup( applyAuditMask( entityPersister.getPropertyInsertability() ), null, null );\n\t\tthis.transactionEndUpdateMutationGroup = buildTransactionEndUpdateMutationGroup();\n\t}\n\n\tpublic EntityPersister getEntityPersister() {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/EntityAuditSupport.java#L104-L140","documentation":"EntityAuditSupport wraps an entity persister for Hibernate's built-in auditing / changeset coordination. Its constructor requires entityPersister.getAuditMapping() to be non-null; MappingException 'No audit mapping available for <entity>' means audit support was constructed for an entity whose mapping never configured auditing. The failure happens while wiring audit support, not while reading or writing audit data.","triggerScenarios":"Enabling the audit/changeset coordinator and then requesting audit services for an entity that lacks the audit mapping - e.g. only some classes of a hierarchy (or only some entities of the unit of work) are annotated for auditing; programmatic mappings that skip audit configuration; code asking for audit state of an un-audited entity type.","commonSituations":"Rolling out auditing per-entity and missing the hierarchy root or one subclass; mixing Envers-style annotations with the built-in coordinator; config that assumes global auditing while the mapping enables it per class.","solutions":["Add the audit mapping to the entity using the auditing configuration your Hibernate version provides (e.g. the audit annotation on the entity)","Apply it to the whole hierarchy - subclass persisters are constructed from the root configuration","Audit-check every entity type your code calls audit/changeset APIs for before enabling the coordinator","If auditing is optional for some entities, guard call sites so audit APIs are only used for audited types"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before enabling the audit coordinator: every audited-API target must have an audit mapping\nEntityPersister p = factory.getRuntimeMetamodels().getMappingMetamodel()\n        .getEntityDescriptor(entityName);\nif (p.getAuditMapping() == null) {\n    throw new IllegalArgumentException(\"Entity not configured for auditing: \" + entityName);\n}","typeGuard":null,"tryCatchPattern":"try { auditApi.forEntity(entityName); } catch (MappingException e) { if (e.getMessage().contains(\"No audit mapping\")) { /* skip or configure auditing for this entity */ } }","preventionTips":["Annotate whole hierarchies, not isolated classes, when enabling auditing","Keep a list of audited entity names and check membership before calling audit APIs","Validate audit coverage in a SessionFactory bootstrap test"],"tags":["hibernate","orm","auditing","changeset","mapping","session-factory-boot"],"backgroundTag":"audit-mapping-missing","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}