Skip to content

Commit c66b27d

Browse files
quaffgavinking
authored andcommitted
HHH-18674 Expose result count of NonUniqueResultException
1 parent 40591ad commit c66b27d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

hibernate-core/src/main/java/org/hibernate/NonUniqueResultException.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,25 @@
1515
* @author Gavin King
1616
*/
1717
public class NonUniqueResultException extends HibernateException {
18+
19+
private final int resultCount;
20+
1821
/**
1922
* Constructs a {@code NonUniqueResultException}.
2023
*
2124
* @param resultCount The number of actual results.
2225
*/
2326
public NonUniqueResultException(int resultCount) {
2427
super( "Query did not return a unique result: " + resultCount + " results were returned" );
28+
this.resultCount = resultCount;
29+
}
30+
31+
/**
32+
* Get the number of actual results.
33+
* @return number of actual results
34+
*/
35+
public int getResultCount() {
36+
return this.resultCount;
2537
}
2638

2739
}

0 commit comments

Comments
 (0)