{"record":{"id":"62d3cf28142ee759","repo":"hibernate/hibernate-orm","slug":"the-insert-statement-for-table-s-contains-no-co","errorCode":null,"errorMessage":"The INSERT statement for table [%s] contains no column, and this is not supported by [%s]","messagePattern":"The INSERT statement for table \\[(.+?)\\] contains no column, and this is not supported by \\[(.+?)\\]","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HANALegacySqlAstTranslator.java","lineNumber":311,"sourceCode":"\t\t}\n\t}\n\n\t@Override\n\tprotected void renderPartitionItem(Expression expression) {\n\t\tif ( expression instanceof Literal ) {\n\t\t\tappendSql( \"grouping sets (())\" );\n\t\t}\n\t\telse if ( expression instanceof Summarization ) {\n\t\t\tthrow new UnsupportedOperationException( \"Summarization is not supported by DBMS\" );\n\t\t}\n\t\telse {\n\t\t\texpression.accept( this );\n\t\t}\n\t}\n\n\t@Override\n\tprotected void renderInsertIntoNoColumns(TableInsertStandard tableInsert) {\n\t\tthrow new MappingException(\n\t\t\t\tString.format(\n\t\t\t\t\t\t\"The INSERT statement for table [%s] contains no column, and this is not supported by [%s]\",\n\t\t\t\t\t\ttableInsert.getMutatingTable().getTableId(),\n\t\t\t\t\t\tgetDialect()\n\t\t\t\t)\n\t\t);\n\t}\n\n\t@Override\n\tprotected void visitValuesList(List<Values> valuesList) {\n\t\tvisitValuesListEmulateSelectUnion( valuesList );\n\t}\n\n\t@Override\n\tpublic void visitValuesTableReference(ValuesTableReference tableReference) {\n\t\temulateValuesTableReferenceColumnAliasing( tableReference );\n\t}\n}","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HANALegacySqlAstTranslator.java#L293-L329","documentation":"Thrown by HANALegacySqlAstTranslator.renderInsertIntoNoColumns() when Hibernate must render an INSERT statement whose target table has no insertable column at all (every column is generated, read-only, or defaulted by the database). The legacy HANA translator has no syntax (such as INSERT ... DEFAULT VALUES or VALUES (0)) to emit for an empty column list, so it raises a MappingException naming the table and dialect.","triggerScenarios":"Persisting or executing 'insert into Entity select ...' for an entity whose mapped columns are all non-insertable (identity/generated/immutable) on HANALegacyDialect; also HQL insert statements whose target column list resolves to zero columns.","commonSituations":"Entities mapping audit/trigger-maintained tables where every column is @Generated or insertable=false; HQL INSERT ... SELECT statements copied from another database; tables that only contain DB-side defaults plus an identity key.","solutions":["Give the table/entity at least one insertable column (drop @Generated or insertable=false on one mapped attribute, or add a writable column)","Insert into such tables through a native SQL statement (the DB can then apply its defaults, e.g. INSERT INTO t VALUES (DEFAULT))","Review the mapping: if all columns are generated, consider a @Immutable/database-only table and stop inserting through Hibernate"],"exampleFix":"// before\n@Entity\n@Table(name = \"audit_log\")\nclass AuditLog {\n    @Id @GeneratedValue Long id;          // generated\n    @Generated @Insertable(false) Instant ts; // generated\n}\nsession.persist(new AuditLog()); // -> INSERT with no columns -> MappingException\n\n// after\n@Query(value = \"insert into audit_log values (default)\", nativeQuery = true)\nvoid insertDefault(); // or make one column insertable, e.g. a writable source column","handlingStrategy":"validation","validationCode":"// fail fast when the target entity has no insertable columns\nEntityPersister p = ((SessionFactoryImplementor) sessionFactory)\n        .getMappingMetamodel().getEntityPersister(Entity.class);\nboolean noneInsertable = Arrays.stream(p.getPropertyInsertability()).noneMatch(b -> b);\nif ( noneInsertable ) {\n    // INSERT cannot be rendered on this dialect - use native SQL\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.persist(entity);\n} catch (MappingException e) {\n    if ( String.valueOf(e.getMessage()).contains(\"contains no column\") ) {\n        // route to a native INSERT ... VALUES (DEFAULT)\n    }\n    throw e;\n}","preventionTips":["Never map an entity where every column is @Generated or insertable=false if you need to insert through Hibernate","Review HQL insert-select targets: the target column list must resolve to at least one insertable column","Add an integration test that persists one instance of every entity on the production dialect to catch mapping-only-insert gaps"],"tags":["hibernate","sap-hana","insert","mapping","generated-columns"],"backgroundTag":"hibernate-mapping-exception","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}