{"record":{"id":"27e42be705cc2c9e","repo":"flowable/flowable-engine","slug":"no-insert-statement-for-entities-iterator-next","errorCode":null,"errorMessage":"no insert statement for ${entities.iterator().next().getClass()} in the ibatis mapping files","messagePattern":"no insert statement for (.+?) in the ibatis mapping files","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSession.java","lineNumber":553,"sourceCode":"    protected void flushBulkInsert(Collection<Entity> entities, Class<? extends Entity> clazz) {\n        String insertStatement = dbSqlSessionFactory.getBulkInsertStatement(clazz);\n        insertStatement = dbSqlSessionFactory.mapStatement(insertStatement);\n\n        if (insertStatement == null) {\n            throw new FlowableException(\"no insert statement for \" + entities.iterator().next().getClass() + \" in the ibatis mapping files\");\n        }","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSession.java#L535-L571","documentation":"Thrown by DbSqlSession.flushBulkInsert when the bulk insert statement mapped for an entity class resolves to null after dbSqlSessionFactory mapping. It means the entity's ibatis mapping file does not define (or does not register) the bulk insert statement required to persist that entity type.","triggerScenarios":"Flushing a collection of new entities of a type whose DbSqlSessionFactory has no bulk insert statement registered, e.g. an entity whose mapping XML lacks the insert statement, or a custom entity added without registering insertStatement/bulkInsertStatement names.","commonSituations":"Adding a custom entity/EntityManager without adding the corresponding MyBatis mapping XML; upgrading Flowable and using a custom DbSqlSessionFactory with stale statement mappings; typos in the statement name returned by the entity's getPersistentState-related insert mapping.","solutions":["Add the bulk insert statement to the entity's ibatis mapping XML file (check the mapping is on the classpath and loaded).","Register/override the insert statement mapping in DbSqlSessionFactory (setInsertStatement/setBulkInsertStatement) for the entity class.","Verify the mapped statement name survives mapStatement (database-type specific prefixes) and exists for your DB type.","If using a custom entity, extend EntityImpl and follow the pattern of a built-in entity, including its XML mapper entry in the SqlSessionFactory configuration."],"exampleFix":"// before (custom entity, no mapping)\n<insert id=\"insertMyEntity\">...</insert>\n// after (add the bulk insert variant used by flushBulkInsert)\n<insert id=\"bulkInsertMyEntity\" parameterType=\"java.util.Collection\">INSERT INTO MY_ENTITY (...) VALUES <foreach ...>(...)</foreach></insert>","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["database","ibatis","persistence","missing-statement"],"backgroundTag":"internal-invariant-violation","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}