{"record":{"id":"adf5f978ba8aca2b","repo":"flowable/flowable-engine","slug":"unsupported-primary-key-type-for-jpa-entity","errorCode":null,"errorMessage":"Unsupported Primary key type for JPA-Entity: ","messagePattern":"Unsupported Primary key type for JPA-Entity: ","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/variable/JPAEntityMappings.java","lineNumber":170,"sourceCode":"            return Integer.parseInt(string);\n        } else if (type == Float.class || type == float.class) {\n            return Float.parseFloat(string);\n        } else if (type == Double.class || type == double.class) {\n            return Double.parseDouble(string);\n        } else if (type == Character.class || type == char.class) {\n            return Character.valueOf(string.charAt(0));\n        } else if (type == java.util.Date.class) {\n            return new java.util.Date(Long.parseLong(string));\n        } else if (type == java.sql.Date.class) {\n            return new java.sql.Date(Long.parseLong(string));\n        } else if (type == BigDecimal.class) {\n            return new BigDecimal(string);\n        } else if (type == BigInteger.class) {\n            return new BigInteger(string);\n        } else if (type == UUID.class) {\n            return UUID.fromString(string);\n        } else {\n            throw new ActivitiIllegalArgumentException(\"Unsupported Primary key type for JPA-Entity: \" + type.getName());\n        }\n    }\n\n    public String getIdString(Object value) {\n        if (value == null) {\n            throw new ActivitiIllegalArgumentException(\"Value of primary key for JPA-Entity cannot be null\");\n        }\n        // Only java.sql.date and java.util.date require custom handling, the other types\n        // can just use toString()\n        if (value instanceof java.util.Date) {\n            return String.valueOf(((java.util.Date) value).getTime());\n        } else if (value instanceof java.sql.Date) {\n            return String.valueOf(((java.sql.Date) value).getTime());\n        } else if (value instanceof Long || value instanceof String || value instanceof Byte\n                || value instanceof Short || value instanceof Integer || value instanceof Float\n                || value instanceof Double || value instanceof Character || value instanceof BigDecimal\n                || value instanceof BigInteger\n                || value instanceof UUID) {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/variable/JPAEntityMappings.java#L152-L188","documentation":"createId converts the stored string representation of a primary key back to the entity's id type. Only a fixed set of types (Long, Integer, String, Short, Double, Float, BigDecimal, BigInteger, UUID) is supported; anything else throws this error.","triggerScenarios":"An entity's @Id is of a type outside the supported list (e.g. java.util.Date, char, byte[], or a custom @Embeddable key class) and a JPA entity variable is stored or read.","commonSituations":"Composite/@EmbeddedId key classes; ids typed as Date or custom value objects; entities migrated to jakarta/javax types not covered by this legacy (flowable5) mapping code.","solutions":["Change the @Id to a supported type (Long, String, UUID, etc.)","Add a surrogate numeric/string primary key and keep the business key as a normal column","Handle the id conversion yourself and store the id as a plain string/long variable instead of a JPA entity variable","Upgrade to an engine version whose JPA mapping supports the desired id type"],"exampleFix":"// before\n@Entity public class Order { @Id private Date created; }\n// after\n@Entity public class Order { @Id private Long id; private Date created; }","handlingStrategy":"validation","validationCode":"Set<Class<?>> supported = Set.of(Long.class, Integer.class, String.class, Short.class,\n    Double.class, Float.class, BigDecimal.class, BigInteger.class, UUID.class);\nField idField = findIdField(entityClass);\nif (!supported.contains(idField.getType())) {\n    throw new IllegalArgumentException(\"Unsupported id type: \" + idField.getType());\n}","typeGuard":"boolean hasSupportedIdType(Class<?> entityClass) {\n    return supportedIdTypes.contains(getIdFieldType(entityClass));\n}","tryCatchPattern":"try {\n    Object entity = mappings.getJPAEntity(className, idString);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unsupported Primary key type\")) {\n        // convert id manually or switch entity id to a supported type\n    } else { throw e; }\n}","preventionTips":["Use Long/String/UUID primary keys for entities stored as variables","Avoid Date, byte[], and custom embeddable ids with this mapping","Verify id type support before adopting an entity as a process variable"],"tags":["jpa","primary-key","unsupported-type"],"backgroundTag":"unsupported-operation","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"}