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 9346c28c8e
commit 84cdd7c93f
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 + "]" );
}
}