{"record":{"id":"ea348fb0979de8d1","repo":"flowable/flowable-engine","slug":"unsupported-primary-key-type-for-jpa-entity-typ","errorCode":null,"errorMessage":"Unsupported Primary key type for JPA-Entity: ${type}","messagePattern":"Unsupported Primary key type for JPA-Entity: (.+?)","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityMappings.java","lineNumber":162,"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 FlowableIllegalArgumentException(\"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 FlowableIllegalArgumentException(\"Value of primary key for JPA-Entity cannot be null\");\n        }\n        // Only java.util.Date requires custom handling,\n        // the other types 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 Long || value instanceof String || value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Float || value instanceof Double\n                || value instanceof Character || value instanceof BigDecimal || value instanceof BigInteger || value instanceof UUID) {\n            return value.toString();\n        } else {\n            throw new FlowableIllegalArgumentException(\"Unsupported Primary key type for JPA-Entity: \" + value.getClass().getName());\n        }\n    }","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityMappings.java#L144-L180","documentation":"Flowable's JPA variable support can only map JPA entity primary keys of a fixed set of Java types (String, Long, Integer, Float, Double, Byte, Short, Character, Boolean, BigDecimal, BigInteger, java.util.Date, UUID). When a JPA entity uses a primary key of any other type, createId throws this error instead of silently producing a wrong key string.","triggerScenarios":"Calling createId (via primaryKey -> getJPAIdString) on an entity whose @Id field type is not in the supported set — e.g. a custom @Embeddable key class, char[] wrapper, or enum-typed @Id — during JPA variable lookups.","commonSituations":"Projects migrating from Hibernate-native composite/embedded ids to Flowable variables; entities using custom Serializable key classes; enum-annotated primary keys.","solutions":["Change the @Id field type of the JPA entity to one of the supported types (String, Long, Integer, UUID, BigDecimal, BigInteger, Date, etc.).","If a custom key class is required, store the entity's natural key in a separate supported-type field and use that as @Id (e.g. replace composite id with a String key).","Avoid storing/looking up that entity as a Flowable JPA variable; keep the reference yourself in a custom variable type.","If the type genuinely belongs in the supported set, verify no generic type erasure makes `type` resolve to Object."],"exampleFix":"// before\n@Id\nprivate CompoundKey id; // custom class -> throws\n// after\n@Id\nprivate String id; // supported type","handlingStrategy":"validation","validationCode":"private static final Set<Class<?>> SUPPORTED = Set.of(String.class, Long.class, Integer.class, Short.class, Byte.class, Float.class, Double.class, Character.class, Boolean.class, BigDecimal.class, BigInteger.class, java.util.Date.class, java.util.UUID.class);\nif (!SUPPORTED.contains(entity.getClass().getMethod(\"getId\").getReturnType())) throw new IllegalArgumentException(entity + \" uses unsupported @Id type\");","typeGuard":"boolean hasSupportedId(Object e) { try { return SUPPORTED.contains(e.getClass().getMethod(\"getId\").getReturnType()); } catch (Exception ex) { return false; } }","tryCatchPattern":"try { variables.put(\"entity\", jpaEntity); } catch (FlowableIllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported Primary key type\")) { throw new ConfigurationException(\"Entity @Id type not supported by Flowable JPA variables\"); } throw e; }","preventionTips":["Declare @Id fields only as String, Long, Integer or UUID in entities used as Flowable variables.","Add an architecture/unit test asserting every @Entity used in variables has a supported key type.","Document supported key types next to JPA variable usage in the codebase."],"tags":["jpa","primary-key","unsupported-type","flowable"],"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"}