Grails No row with the given identifier exists: [Category#0]
Problem
If you have grails errors message:
Grails No row with the given identifier exists: [Category#0]
it means that data consistency of your app is broken.
Solution
-
First you need to decipher the message. It says that you have class named Category and you are trying to reference an object with id - 0 . Since this row with id doesn't exist you get this error.
-
Next you need to find where and who is trying to get information about this object. This can be done by checking the stack trace of the application.
at java.util.HashMap.containsKey(HashMap.java:596)
at Book.BookController.$tt__index(BookController.groovy:30)
at grails.gorm.transactions.GrailsTransactionTemplate$2.doInTransaction
(GrailsTransactionTemplate.groovy:94)
at org.springframework.transaction.support.TransactionTemplate.execute
(TransactionTemplate.java:133)
at grails.gorm.transactions.GrailsTransactionTemplate.execute
(GrailsTransactionTemplate.groovy:91)
... 39 common frames omitted
As you can see it's called from BookController line 30. So most probably while searching for Book you get this error ( better to check the code).
- Last step is to fix currupted data by:
- add this information in table Category
- update reference table - Book and the field which points to Category with appropriate value