{"record":{"id":"23f602ba7e82edbf","repo":"flowable/flowable-engine","slug":"value-is-not-a-list-of-jpa-entities","errorCode":null,"errorMessage":"Value is not a list of JPA entities: ","messagePattern":"Value is not a list of JPA entities: ","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java","lineNumber":117,"sourceCode":"        }\n\n        if (value instanceof List<?> list && list.size() > 0) {\n            List<String> ids = new ArrayList<>();\n\n            String type = mappings.getJPAClassString(list.get(0));\n            for (Object entry : list) {\n                ids.add(mappings.getJPAIdString(entry));\n            }\n\n            // Store type in text field and the ID's as a serialized array\n            valueFields.setBytes(serializeIds(ids));\n            valueFields.setTextValue(type);\n\n        } else if (value == null) {\n            valueFields.setBytes(null);\n            valueFields.setTextValue(null);\n        } else {\n            throw new FlowableIllegalArgumentException(\"Value is not a list of JPA entities: \" + value);\n        }\n\n    }\n\n    @Override\n    public Object getValue(ValueFields valueFields) {\n        byte[] bytes = valueFields.getBytes();\n        if (valueFields.getTextValue() != null && bytes != null) {\n            String entityClass = valueFields.getTextValue();\n\n            List<Object> result = new ArrayList<>();\n            String[] ids = deserializeIds(bytes);\n\n            for (String id : ids) {\n                result.add(mappings.getJPAEntity(entityClass, id));\n            }\n\n            return result;","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java#L99-L135","documentation":"JPAEntityListVariableType.setValue only accepts null, a value resolvable to an entity class name, or a List of JPA entities. If the value is neither (some other object type), it throws FlowableIllegalArgumentException stating the value is not a list of JPA entities.","triggerScenarios":"Setting a variable whose VariableType resolves to JPAEntityListVariableType with a non-list, non-entity object (e.g. a plain String, Map, or single non-entity POJO), causing execution to fall into the final else branch.","commonSituations":"Passing a single entity where the variable type expects a List; passing a collection of non-entities; type confusion when reusing an existing variable slot previously bound to a JPA list type.","solutions":["Pass a java.util.List of JPA-annotated entities, or null to clear","Ensure each element is an entity recognized by Flowable's entity scanner (@Entity annotated)","Use JPAEntityVariableType for a single entity instead of the list type","Verify no earlier variable with the same name forced this type via setVariable type detection"],"exampleFix":"// before\nruntimeService.setVariable(executionId, \"customers\", singleCustomer); // wrong type for list var\n// after\nruntimeService.setVariable(executionId, \"customers\", java.util.Arrays.asList(customerA, customerB));","handlingStrategy":"type-guard","validationCode":"boolean validListValue(Object v) {\n    return v == null || (v instanceof java.util.List\n        && ((java.util.List<?>) v).stream().allMatch(e -> e.getClass().isAnnotationPresent(jakarta.persistence.Entity.class)));\n}","typeGuard":"boolean isJpaEntityList(Object v) { return v instanceof java.util.List && !((java.util.List<?>) v).isEmpty() && ((java.util.List<?>) v).stream().allMatch(e -> e.getClass().isAnnotationPresent(jakarta.persistence.Entity.class)); }","tryCatchPattern":"try { runtimeService.setVariable(executionId, \"customers\", value); } catch (FlowableIllegalArgumentException e) { if (e.getMessage().startsWith(\"Value is not a list of JPA entities\")) { throw new IllegalArgumentException(\"Pass a List<JPA-entity> or null\"); } throw e; }","preventionTips":["Use JPAEntityVariableType for single entities and JPAEntityListVariableType only for Lists","Type-check values against @Entity before setting variables","Let Flowable auto-detect the type instead of forcing a list type for non-list values"],"tags":["jpa","type-mismatch","variables","flowable"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}