{"record":{"id":"4e959c06bd3493f0","repo":"hibernate/hibernate-orm","slug":"the-insert-statement-for-table-s-contains-no-co-4e959c","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-core/src/main/java/org/hibernate/sql/Insert.java","lineNumber":136,"sourceCode":"\t\tthis.tableName = tableName;\n\t\treturn this;\n\t}\n\n\tpublic String toStatementString() {\n\t\tfinal StringBuilder buf = new StringBuilder( columns.size()*15 + tableName.length() + 10 );\n\n\t\tif ( comment != null ) {\n\t\t\tbuf.append( \"/* \" ).append( Dialect.escapeComment( comment ) ).append( \" */ \" );\n\t\t}\n\n\t\tbuf.append( \"insert into \" ).append( tableName );\n\n\t\tif ( columns.isEmpty() ) {\n\t\t\tif ( dialect.supportsNoColumnsInsert() ) {\n\t\t\t\tbuf.append( ' ' ).append( dialect.getNoColumnsInsertString() );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\tString.format(\n\t\t\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\t\t\ttableName,\n\t\t\t\t\t\t\t\tdialect\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tbuf.append( \" (\" );\n\t\t\trenderInsertionSpec( buf );\n\t\t\tbuf.append( \") values (\" );\n\t\t\trenderRowValues( buf );\n\t\t\tbuf.append( ')' );\n\t\t}\n\t\treturn buf.toString();\n\t}\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/sql/Insert.java#L118-L154","documentation":"While rendering an INSERT statement, Hibernate found zero columns to include — every mapped column of the table is generated, virtual, or insertable=false. If the dialect does not support no-column inserts (supportsNoColumnsInsert() == false, e.g. Oracle), it cannot produce valid SQL and throws MappingException naming the table and the dialect.","triggerScenarios":"An entity whose columns are all database-generated (defaults, triggers, identity) being persisted on a dialect without 'insert into t default values' support; mappings where every column has insertable=false; insert-only generated properties with no regular columns left.","commonSituations":"Audit/log tables populated entirely by triggers; tables where the app supplies no columns; switching an application from SQL Server/H2 (supports DEFAULT VALUES) to Oracle; overuse of insertable=false in composite mappings.","solutions":["Give the entity at least one insertable column the application can write","Check dialect capability up front: dialect.supportsNoColumnsInsert() — if false, such mappings cannot be inserted via Hibernate","For trigger/default-populated tables with no writable columns, use a native SQL insert or a @SQLInsert override","Revisit insertable=false / @Generated usage — you may have accidentally excluded every column"],"exampleFix":"// before\n@Entity\n@Table(name = \"audit_log\")\npublic class AuditLog {\n    @Id @GeneratedValue Long id;              // generated\n    @Column(insertable = false) String user;  // DB default -> zero insertable columns on Oracle\n}\n\n// after\n@Entity\n@Table(name = \"audit_log\")\npublic class AuditLog {\n    @Id @GeneratedValue Long id;\n    String user; // let Hibernate insert it (or use a native insert)","handlingStrategy":"validation","validationCode":"// startup audit: mappings with zero insertable columns need dialect support\nDialect dialect = sessionFactory.getJdbcServices().getDialect();\nif (!dialect.supportsNoColumnsInsert()) {\n    for (EntityBinding b : metadata.getEntityBindings()) {\n        if (b.getInsertableColumnCount() == 0) {\n            LOG.error(\"table {} has no insertable columns; dialect {} cannot insert it\",\n                      b.getTableName(), dialect);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check dialect.supportsNoColumnsInsert() before mapping all-generated-column tables","Keep at least one application-writable insertable column per entity","For trigger-populated tables, prefer native insert statements or @SQLInsert"],"tags":["mapping","insert","dialect","sql-generation"],"backgroundTag":"mapping-misconfiguration","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}