slightly improve format of error message

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-04-24 21:31:30 +02:00
parent 181399f84c
commit b102a6e2c9
2 changed files with 7 additions and 5 deletions

View File

@ -495,7 +495,8 @@ public class QuerySqmImpl<R>
}
catch (IllegalQueryOperationException e) {
// per JPA
throw new IllegalStateException( "Expecting a SELECT query : `" + hql + "`", e );
throw new IllegalStateException( "Query executed via 'getResultList()' or 'getSingleResult()' must be a 'select' query ["
+ hql + "]", e );
}
}
@ -656,7 +657,8 @@ public class QuerySqmImpl<R>
}
catch (IllegalQueryOperationException e) {
// per JPA
throw new IllegalStateException( "Expecting a non-SELECT query : `" + hql + "`", e );
throw new IllegalStateException( "Query executed via 'executeUpdate()' must be an 'insert', 'update', or 'delete' statement ["
+ hql + "]", e );
}
}

View File

@ -41,7 +41,7 @@ public class QueryApiTests {
catch (IllegalStateException ise) {
assertThat( ise.getCause() ).isNotNull();
assertThat( ise.getCause() ).isInstanceOf( IllegalQueryOperationException.class );
assertThat( ise.getMessage() ).endsWith( "`" + hql + "`" );
assertThat( ise.getMessage() ).endsWith( "[" + hql + "]" );
}
}
@ -57,7 +57,7 @@ public class QueryApiTests {
catch (IllegalStateException ise) {
assertThat( ise.getCause() ).isNotNull();
assertThat( ise.getCause() ).isInstanceOf( IllegalQueryOperationException.class );
assertThat( ise.getMessage() ).endsWith( "`" + hql + "`" );
assertThat( ise.getMessage() ).endsWith( "[" + hql + "]" );
}
} );
@ -70,7 +70,7 @@ public class QueryApiTests {
catch (IllegalStateException ise) {
assertThat( ise.getCause() ).isNotNull();
assertThat( ise.getCause() ).isInstanceOf( IllegalQueryOperationException.class );
assertThat( ise.getMessage() ).endsWith( "`" + hql + "`" );
assertThat( ise.getMessage() ).endsWith( "[" + hql + "]" );
}
}