Most OpenMRS objects, especially since the advent of REST, have get<T>byUuid methods with signatures declaring that they throw an API exception, but get the object by using a parameter query with .uniqueResult() and without a try-catch block. .uniqueResult returns null if there is no match and throws a Hibernate exception if there are multiple results. We rely on a unique DB constraint to keep the results singular, so perhaps a try-catch loop to change from a Hibernate to an API exception is unnecessary, but in that case there’s no circumstance where the API Exception would be thrown. Could someone confirm that returning null rather than throwing the exception is the desired behavior?
[OPENMRS-DEV] getbyUuid and REST
Friedman, Roger (CDC/CGH/DGHA) (CTR) Sun, 22 Jan 2012 10:44:59 -0800
- [OPENMRS-DEV] get<T>byUuid and ... Friedman, Roger (CDC/CGH/DGHA) (CTR)
- Re: [OPENMRS-DEV] get<T>by... Ben Wolfe

