hibernate/hibernate-orm · error · SemanticException
Search attribute '%s' not found in the CTE %s
Error message
Search attribute '%s' not found in the CTE %s
What it means
Error "Search attribute '%s' not found in the CTE %s" thrown in hibernate/hibernate-orm.
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)
Solutions
- Define the search attribute in the CTE matching an exposed CTE column.
- Check the attribute name against the CTE definition.
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.