hibernate/hibernate-orm · error · IllegalArgumentException
A CTE object with the name " + name + " already exists
Error message
A CTE object with the name " + name + " already exists
What it means
Error "A CTE object with the name " + name + " already exists" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/sql/ast/tree/AbstractStatement.java:75
@Override
public Map<String, CteObject> getCteObjects() {
return cteObjects;
}
@Override
public CteObject getCteObject(String cteObjectName) {
final var cteObject = cteObjects.get( cteObjectName );
return cteObject == null
&& parentCteContainer != null
? parentCteContainer.getCteObject( cteObjectName )
: cteObject;
}
@Override
public void addCteObject(CteObject cteObject) {
final String name = cteObject.getName();
if ( cteObjects.putIfAbsent( name, cteObject ) != null ) {
throw new IllegalArgumentException( "A CTE object with the name " + name + " already exists" );
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Ensure each CTE name in the query is unique; a CTE object with this name was already registered on the statement.
- Rename one of the duplicate CTEs or merge their definitions.
When it happens
Trigger: A CTE object is registered under a name that already exists: " + name + ".
Common situations: Adding duplicate with-clause CTEs of the same name to a Criteria/HQL query, typically from repeated query-construction code paths.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/8d33ce08a7023d09.
Report an issue: GitHub.