{"record":{"id":"c831f6de1026f0b3","repo":"greenrobot/greenDAO","slug":"type-is-already-non-primitive","errorCode":null,"errorMessage":"Type is already non-primitive","messagePattern":"Type is already non-primitive","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"DaoGenerator/src/org/greenrobot/greendao/generator/Property.java","lineNumber":97,"sourceCode":"                        \"AUTOINCREMENT is only available to primary key properties of type long/Long\");\n            }\n            property.pkAutoincrement = true;\n            return this;\n        }\n\n        public PropertyBuilder unique() {\n            property.unique = true;\n            return this;\n        }\n\n        public PropertyBuilder notNull() {\n            property.notNull = true;\n            return this;\n        }\n\n        public PropertyBuilder nonPrimitiveType() {\n            if (!property.propertyType.isScalar()) {\n                throw new RuntimeException(\"Type is already non-primitive\");\n            }\n            property.nonPrimitiveType = true;\n            return this;\n        }\n\n        public PropertyBuilder index() {\n            Index index = new Index();\n            index.addProperty(property);\n            property.entity.addIndex(index);\n            return this;\n        }\n\n        public PropertyBuilder indexAsc(String indexNameOrNull, boolean isUnique) {\n            Index index = new Index();\n            index.addPropertyAsc(property);\n            if (isUnique) {\n                index.makeUnique();\n            }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/greenrobot/greenDAO/blob/0bbb338e17c4cf28aba5aae62d42f73f50186157/DaoGenerator/src/org/greenrobot/greendao/generator/Property.java#L79-L115","documentation":"PropertyBuilder.nonPrimitiveType() is meant to mark a scalar property as a non-primitive Java type (e.g. use Long instead of long in generated code). If the property's PropertyType is not scalar, the conversion makes no sense and the generator aborts with a RuntimeException. It is a config-time sanity check: you can only 'un-primitivize' primitive-typed properties.","triggerScenarios":"Calling PropertyBuilder.nonPrimitiveType() (or the .javaDocNotNull chain equivalent) on a property whose type is already an object type, e.g. a String, byte[], or Date property that was never declared notNull/primitive.","commonSituations":"Copy-pasting a property declaration and adding .nonPrimitiveType() to a String property; applying a shared property-builder helper to properties of mixed types; API changes where a property previously scalar became a blob/String type.","solutions":["Remove the .nonPrimitiveType() call from properties that are already object/reference types","Only apply .nonPrimitiveType() to scalar types (boolean, int, long, float, double, short, byte, char)","Check the property's PropertyType.isScalar() before calling nonPrimitiveType()","If the property should be primitive-typed, declare it with a scalar type first"],"exampleFix":"// before\nProperty name = user.addStringProperty(\"name\").nonPrimitiveType().getProperty();\n// after\nProperty name = user.addStringProperty(\"name\").getProperty(); // String is already non-primitive","handlingStrategy":"validation","validationCode":"if (propertyType.isScalar()) { builder.nonPrimitiveType(); }","typeGuard":"function isScalar(pt) { return ['boolean','int','long','float','double','short','byte','char'].includes(pt); }","tryCatchPattern":"try { builder.nonPrimitiveType(); } catch (RuntimeException e) { if (e.getMessage().contains(\"non-primitive\")) { /* skip: already object type */ } else { throw e; } }","preventionTips":["Only call nonPrimitiveType() on properties created with scalar addXxxProperty methods","Centralize property-building helpers so the type is known before applying modifiers","Read PropertyType.isScalar() docs before using nonPrimitiveType"],"tags":["greendao","codegen","config-error","property-type"],"backgroundTag":"invalid-argument-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"}