In Cosminexus JPA Provider, if there is a syntactic error in a query-related annotation, an exception occurs when the application is deployed. Also, if the arguments of the query-related method are invalid and if the specified string is not a valid JPQL string, the IllegalArgumentException exception occurs or the execution of the query fails.
If the query is not valid for the database query that uses a native query or if the defined result set is not compatible with the query result, the execution of the query fails. In Cosminexus JPA Provider, the PersistenceException exception is thrown during the execution of the query.
- Organization of this subsection
- (1) Exceptions thrown in the API functions of the query-related interfaces in EntityManager
- (2) Exceptions thrown in the API functions of the Query interface
The exceptions thrown in the API functions of the Query interface are as follows:
- If the JPQL UPDATE statement or DELETE statement is invoked with the getResultList method, the IllegalStateException exception is thrown.
- If the query result does not exist, the NoResultException exception is thrown in the getSingleResult method. Note that if there are two or more query results, the NonUniqueResultException exception is thrown. If the JPQL UPDATE statement or DELETE statement is invoked, the IllegalStateException exception is thrown.
- If the JPQL SELECT statement is invoked with the executeUpdate method, the IllegalStateException exception is thrown. At this time, if the transaction does not exist, the TransactionRequiredException exception is thrown.
- If the second argument of the setHint method is not correct for implementation, the IllegalArgumentException exception is thrown.
- If the position of the arguments for the setParameter method does not match with the location parameter of the query, or if the parameter name of the argument does not match with the parameter of the query string, the IllegalArgumentException exception is thrown.
- If the arguments of the setMaxResults or setFirstResult method are negative, the IllegalArgumentException exception is thrown.
For details on the API functions, see the Java documentation.