hibernate/hibernate-orm · error · IllegalArgumentException

requested tuple index must be greater than zero

Error message

requested tuple index must be greater than zero

What it means

Index validation in NativeTupleImpl.get(int): the requested index is negative. Tuple element access is zero-based; the faulty input is the negative index argument.

Solutions

  1. Use a 1-based positive index when accessing tuple elements by position.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryTupleTransformer.java:118 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryTupleTransformer.java:118

		public Object get(String alias) {
			final String aliasReference = aliasReferences.get( alias.toLowerCase(ROOT) );
			if ( aliasReference != null && aliasToValue.containsKey( aliasReference ) ) {
				return aliasToValue.get( aliasReference );
			}
			throw new IllegalArgumentException( "Unknown alias [" + alias + "]" );
		}

		@Override
		public <X> X get(int i, Class<X> type) {
			final Object untyped = get( i );

			return ( untyped != null ) ? type.cast( untyped ) : null;
		}

		@Override
		public Object get(int i) {
			if ( i < 0 ) {
				throw new IllegalArgumentException( "requested tuple index must be greater than zero" );
			}
			if ( i >= size ) {
				throw new IllegalArgumentException( "requested tuple index exceeds actual tuple size" );
			}
			return tuple[i];
		}

		@Override
		public Object[] toArray() {
			// todo : make a copy?
			return tuple;
		}

		@Override
		public String toString() {
			return Arrays.toString( tuple );
		}

View on GitHub (pinned to fad1729dce)