hibernate/hibernate-orm · error · MappingException

The INSERT statement for table [%s] contains no column, and

Error message

The INSERT statement for table [%s] contains no column, and this is not supported by [%s]

What it means

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.

Source

Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HANALegacySqlAstTranslator.java:311

		}
	}

	@Override
	protected void renderPartitionItem(Expression expression) {
		if ( expression instanceof Literal ) {
			appendSql( "grouping sets (())" );
		}
		else if ( expression instanceof Summarization ) {
			throw new UnsupportedOperationException( "Summarization is not supported by DBMS" );
		}
		else {
			expression.accept( this );
		}
	}

	@Override
	protected void renderInsertIntoNoColumns(TableInsertStandard tableInsert) {
		throw new MappingException(
				String.format(
						"The INSERT statement for table [%s] contains no column, and this is not supported by [%s]",
						tableInsert.getMutatingTable().getTableId(),
						getDialect()
				)
		);
	}

	@Override
	protected void visitValuesList(List<Values> valuesList) {
		visitValuesListEmulateSelectUnion( valuesList );
	}

	@Override
	public void visitValuesTableReference(ValuesTableReference tableReference) {
		emulateValuesTableReferenceColumnAliasing( tableReference );
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Give the table/entity at least one insertable column (drop @Generated or insertable=false on one mapped attribute, or add a writable column)
  2. Insert into such tables through a native SQL statement (the DB can then apply its defaults, e.g. INSERT INTO t VALUES (DEFAULT))
  3. Review the mapping: if all columns are generated, consider a @Immutable/database-only table and stop inserting through Hibernate

Example fix

// before
@Entity
@Table(name = "audit_log")
class AuditLog {
    @Id @GeneratedValue Long id;          // generated
    @Generated @Insertable(false) Instant ts; // generated
}
session.persist(new AuditLog()); // -> INSERT with no columns -> MappingException

// after
@Query(value = "insert into audit_log values (default)", nativeQuery = true)
void insertDefault(); // or make one column insertable, e.g. a writable source column
Defensive patterns

Strategy: validation

Validate before calling

// fail fast when the target entity has no insertable columns
EntityPersister p = ((SessionFactoryImplementor) sessionFactory)
        .getMappingMetamodel().getEntityPersister(Entity.class);
boolean noneInsertable = Arrays.stream(p.getPropertyInsertability()).noneMatch(b -> b);
if ( noneInsertable ) {
    // INSERT cannot be rendered on this dialect - use native SQL
}

Try / catch

try {
    session.persist(entity);
} catch (MappingException e) {
    if ( String.valueOf(e.getMessage()).contains("contains no column") ) {
        // route to a native INSERT ... VALUES (DEFAULT)
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/62d3cf28142ee759. Report an issue: GitHub.