hibernate/hibernate-orm · error · IllegalArgumentException
ConstructorResult did not define any ColumnResults
Error message
ConstructorResult did not define any ColumnResults
What it means
While interpreting a @SqlResultSetMapping's @ConstructorResult, Hibernate reads constructorResult.columns() and immediately throws this IllegalArgumentException when the array is empty. A constructor result maps each constructor argument from a column, so at least one @ColumnResult is required for the mapping to be meaningful.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/query/SqlResultSetMappingDescriptor.java:243
private final String mappingName;
private final Class<?> targetJavaType;
private final List<ArgumentDescriptor> argumentResultDescriptors;
public ConstructorResultDescriptor(
ConstructorResult constructorResult,
String mappingName) {
this.mappingName = mappingName;
targetJavaType = constructorResult.targetClass();
argumentResultDescriptors = interpretArguments( constructorResult, mappingName );
}
private static List<ArgumentDescriptor> interpretArguments(
ConstructorResult constructorResult,
String mappingName) {
final var columnResults = constructorResult.columns();
if ( isEmpty( columnResults ) ) {
throw new IllegalArgumentException( "ConstructorResult did not define any ColumnResults" );
}
final List<ArgumentDescriptor> argumentResultDescriptors = arrayList( columnResults.length );
for ( var columnResult : columnResults ) {
final var argumentResultDescriptor =
new JpaColumnResultDescriptor( columnResult, mappingName );
argumentResultDescriptors.add( new ArgumentDescriptor(argumentResultDescriptor) );
}
return argumentResultDescriptors;
}
@Nonnull
@Override
public ResultMemento resolve(@Nonnull ResultSetMappingResolutionContext resolutionContext) {
BOOT_QUERY_LOGGER.tracef(
"Generating InstantiationResultMappingMemento for JPA ConstructorResult(%s) for ResultSet mapping `%s`",
targetJavaType.getName(),
mappingNameView on GitHub (pinned to fad1729dce)
Solutions
- Add at least one @ColumnResult whose name matches a column of the native query and whose type matches a constructor parameter.
- Verify every constructor parameter of targetClass has a matching @ColumnResult (count and order).
- If the constructor result is not needed, delete the whole @ConstructorResult entry from @SqlResultSetMapping(classes = ...).
Example fix
// before
@SqlResultSetMapping(classes = {
@ConstructorResult(targetClass = OrderTotal.class, columns = {})
})
// after
@SqlResultSetMapping(classes = {
@ConstructorResult(
targetClass = OrderTotal.class,
columns = { @ColumnResult(name = "orderId"), @ColumnResult(name = "total") }
)
}) Defensive patterns
Strategy: validation
Validate before calling
// reflectively check annotation usage at startup or in a test:
for ( SqlResultSetMapping m : mappings ) {
for ( ConstructorResult c : c.classes() ) {
if ( c.columns().length == 0 ) {
throw new IllegalStateException( "ConstructorResult for " + c.targetClass().getName() + " has no columns" );
}
}
} Type guard
static boolean hasColumns(ConstructorResult c) {
return c.columns() != null && c.columns().length > 0;
} Try / catch
catch ( IllegalArgumentException e ) {
if ( "ConstructorResult did not define any ColumnResults".equals( e.getMessage() ) ) {
// add @ColumnResult entries matching the target constructor's parameters
}
} Prevention
- Write @ConstructorResult from the constructor signature outward: one @ColumnResult per parameter, in order.
- Keep a small unit test that builds the EntityManagerFactory for annotated entities so empty annotations fail in CI.
When it happens
Trigger: @ConstructorResult(targetClass = OrderTotal.class, columns = {}); a @SqlResultSetMapping built reflectively or generated where the columns array was never populated.
Common situations: Annotation scaffolding left half-finished; refactoring that removed columns but kept the constructor result; tools that generate @SqlResultSetMapping skeletons.
Related errors
- Passed FieldResult [%s, %s] does not match AttributeFetchMap
- Class '<componentClassName>' is an '@Embeddable' type and ma
- Property '<propertyName>' may not be annotated '@BatchSize'
- One to many association '<propertyName>' was annotated '@Col
- Collection '<propertyName>' was annotated '@Collate'
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/8bd92243d6dab48e.
Report an issue: GitHub.