Reputation: 31
How can I get around this error message?
query did not return a unique result
Which is being produced from this code:
try {
crnResults = CRN.where {time == timeParam}.get()
} catch (Exception ex) {
flash.message = ex.message + " -- err: 717"
}
Upvotes: 3
Views: 5322
Reputation: 488
If your query has the possibility to return more than one result then you should use .list()
instead of .get()
.
To get only one result from you query with some sort rule, use this:
crnResults = CRN.where { time == timeParam }.list(max: 1, sort: "id", order: "desc")
Otherwise, just use .list()
.
Upvotes: 6