hibernate/hibernate-orm · error · IllegalStateException

Couldn't find table index for

Error message

Couldn't find table index for [${tableExpression}] in: ${declaringEntityPersister.getEntityName()}

What it means

Lookup failure in findTableIndex: the table expression being referenced does not appear among the declaring entity persister's table names, so its positional index cannot be determined.

Solutions

  1. The table expression could not be matched to a table of the entity persister.
  2. Check that the table name used in the mutation matches the entity's mapped tables.
Defensive patterns

Strategy: validation

When it happens

Trigger: A name referenced in the query or its configuration cannot be resolved at runtime.

Common situations: Typos in fetch-profile, memento, or table names, or references to objects that were never registered.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/SqmMutationStrategyHelper.java:394

				forEachSelectableMapping( newPrefix, property.getValue(), consumer );
			}
		}
		else if ( value instanceof OneToMany || value instanceof Collection ) {
			// No-op
		}
		else {
			throw new UnsupportedOperationException( "Unsupported value type: " + value.getClass() );
		}
	}

	private static int findTableIndex(EntityPersister declaringEntityPersister, String tableExpression) {
		final String[] tableNames = declaringEntityPersister.getTableNames();
		for ( int i = 0; i < tableNames.length; i++ ) {
			if ( tableExpression.equals( tableNames[i] ) ) {
				return i;
			}
		}
		throw new IllegalStateException( "Couldn't find table index for [" + tableExpression + "] in: " + declaringEntityPersister.getEntityName() );
	}
}

View on GitHub (pinned to fad1729dce)