HHH-18674 Expose result count of NonUniqueResultException

This commit is contained in:
Yanming Zhou 2024-09-30 09:15:07 +08:00 committed by Gavin King
parent 40591ada20
commit c66b27d193
1 changed files with 12 additions and 0 deletions

View File

@ -15,6 +15,9 @@ import org.hibernate.query.Query;
* @author Gavin King
*/
public class NonUniqueResultException extends HibernateException {
private final int resultCount;
/**
* Constructs a {@code NonUniqueResultException}.
*
@ -22,6 +25,15 @@ public class NonUniqueResultException extends HibernateException {
*/
public NonUniqueResultException(int resultCount) {
super( "Query did not return a unique result: " + resultCount + " results were returned" );
this.resultCount = resultCount;
}
/**
* Get the number of actual results.
* @return number of actual results
*/
public int getResultCount() {
return this.resultCount;
}
}