hibernate/hibernate-orm · error · SemanticException
Search attribute ' ' not found in the CTE
Error message
Search attribute '%s' not found in the CTE %s
What it means
Raised (as SemanticException, formatted via String.format) while applying a recursive CTE 'search' clause: the search attribute name given in 'search set' does not match any attribute of the CTE type. The offending inputs are the unknown search attribute name and the CTE definition against which it was resolved.
Solutions
- Define the search attribute in the CTE matching an exposed CTE column.
- Check the attribute name against the CTE definition.
Defensive patterns
Strategy: validation
When it happens
Trigger: A runtime precondition of the Hibernate API is violated.
Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/8414427062113dcd.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:947
cycleValue = Boolean.TRUE;
noCycleValue = Boolean.FALSE;
}
cyclePathAttributeName = ctx.USING() == null ? null : visitIdentifier( ctx.identifier( 1 ) );
cteDefinition.cycleUsing( cycleMarkAttributeName, cyclePathAttributeName, cycleValue, noCycleValue, cycleAttributes );
}
private void applySearchClause(JpaCteCriteria<?> cteDefinition, HqlParser.SearchClauseContext ctx) {
final String searchAttributeName = visitIdentifier( ctx.identifier() );
final var searchCtx = ctx.searchSpecifications();
final List<JpaSearchOrder> searchOrders = new ArrayList<>( ( searchCtx.getChildCount() + 1 ) >> 1 );
final var searchSpecifications = searchCtx.searchSpecification();
final var type = cteDefinition.getType();
for ( int i = 0; i < searchSpecifications.size(); i ++ ) {
final var specCtx = searchSpecifications.get( i );
final String attributeName = visitIdentifier( specCtx.identifier() );
final var attribute = type.getAttribute( attributeName );
if ( attribute == null ) {
throw new SemanticException(
String.format(
"Search attribute '%s' not found in the CTE %s",
attributeName,
cteDefinition.getName()
),
query
);
}
SortDirection sortOrder = SortDirection.ASCENDING;
Nulls nullPrecedence = Nulls.NONE;
int index = 1;
if ( index < specCtx.getChildCount() ) {
if ( specCtx.getChild( index ) instanceof HqlParser.SortDirectionContext ) {
final var sortCtx = specCtx.sortDirection();
final var symbol = ((TerminalNode) sortCtx.getChild( 0 )).getSymbol();
sortOrder = switch ( symbol.getType() ) {
case HqlParser.ASC -> SortDirection.ASCENDING;
case HqlParser.DESC -> SortDirection.DESCENDING;View on GitHub (pinned to fad1729dce)