I'm using an existing DB from an open source application (OSTicket). There are two tables (OstStaff and OstTicket, where staff hasMany Tickets). However, the big problem is OSTicket assigns a default value of zero to OstTicket.staff_id, when the ticket is not yet assigned to an OstStaff.
The issue arises when you search for tickets and GORM thinks that there is a staff with index equal to 0. I can't even check for null, just keep getting this error:
No row with the given identifier exists: [com.facilities.model.OstFacStaff#0].
Stacktrace follows:
Message: No row with the given identifier exists: [com.facilities.model.OstFacStaff#0]
Any suggestion how I can get around this issue? Thanks.
Solved this by just getting the ids, rather than the record, and then removing the zero index.
def ticketCriteria = OstFacTicket.createCriteria()
def staffIdsWithTickets = ticketCriteria.list {
projections {
distinct("staff.id") // **INSTEAD of returning staff, get the id**
}
between("created", start, end)
}
def zeroIndex = staffIdsWithTickets.indexOf(0)
if (zeroIndex >= 0) {
staffIdsWithTickets.remove(zeroIndex)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.