{"record":{"id":"b6391e8a28ee1f71","repo":"greenrobot/greenDAO","slug":"unsupported-type-type","errorCode":null,"errorMessage":"Unsupported type: ${type}","messagePattern":"Unsupported type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"DaoCore/src/main/java/org/greenrobot/greendao/internal/DaoConfig.java","lineNumber":173,"sourceCode":"        }\n    }\n\n    public void setIdentityScope(IdentityScope<?, ?> identityScope) {\n        this.identityScope = identityScope;\n    }\n\n    @SuppressWarnings(\"rawtypes\")\n    public void initIdentityScope(IdentityScopeType type) {\n        if (type == IdentityScopeType.None) {\n            identityScope = null;\n        } else if (type == IdentityScopeType.Session) {\n            if (keyIsNumeric) {\n                identityScope = new IdentityScopeLong();\n            } else {\n                identityScope = new IdentityScopeObject();\n            }\n        } else {\n            throw new IllegalArgumentException(\"Unsupported type: \" + type);\n        }\n    }\n\n}\n","sourceCodeStart":155,"sourceCodeEnd":178,"githubUrl":"https://github.com/greenrobot/greenDAO/blob/0bbb338e17c4cf28aba5aae62d42f73f50186157/DaoCore/src/main/java/org/greenrobot/greendao/internal/DaoConfig.java#L155-L178","documentation":"initIdentityScope chooses an identity-scope implementation based on the primary key type: numeric keys use IdentityScopeLong, everything else IdentityScopeObject. If the key property type is neither numeric nor String/byte-array eligible, the configuration is unsupported and IllegalArgumentException is thrown.","triggerScenarios":"Configuring a DAO whose primary key property `type` is not a supported key type (e.g. a non-numeric, non-String PK such as Date, Boolean, or a custom object) — passed via `initIdentityScope()` in DaoConfig.","commonSituations":"Declaring an entity with a primary key of an unusual Java type; changing a PK type in the schema without regenerating; custom DaoConfig construction in tests or non-standard setups.","solutions":["Change the entity primary key to a supported type (Long/long is recommended) and regenerate the DAO classes","If a non-Long key is required, ensure the key property type is String or byte[] so IdentityScopeObject is selected","Check the generated DaoConfig constructor to confirm the PK type matches the schema"],"exampleFix":"// before (schema/entity)\n@Entity\npublic class User {\n    @Id\n    private Date createdAt;\n}\n// after\n@Entity\npublic class User {\n    @Id(autoincrement = true)\n    private Long id;\n    @Unique\n    private Date createdAt;\n}","handlingStrategy":"validation","validationCode":"Class<?> pkType = keyProperty.type;\nboolean ok = pkType == Long.class || pkType == long.class || pkType == Integer.class || pkType == int.class\n        || pkType == Short.class || pkType == short.class || pkType == Byte.class || pkType == byte.class\n        || pkType == String.class || pkType == byte[].class;\nif (!ok) throw new IllegalArgumentException(\"Unsupported PK type: \" + pkType);","typeGuard":null,"tryCatchPattern":"try {\n    config.initIdentityScope();\n} catch (IllegalArgumentException e) {\n    // fall back: disable identity scope or fix PK type\n    config.initIdentityScope(null);\n}","preventionTips":["Use Long autoincrement primary keys for entities","Avoid Date/Boolean/custom object primary keys","Regenerate DAOs after changing PK types"],"tags":["greendao","orm","primary-key","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"0bbb338e17c4cf28aba5aae62d42f73f50186157","analyzedAt":"2026-09-08T03:22:36.050Z","contentChangedAt":"2026-09-08T03:22:36.050Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}