grails - testing delete()
I just wonder why one method to test delete() works as expected, but another does not? In the following test case:
def cFound = new Client( ... ).save()
def cFoundId = cFound.id
cFound.delete()
assertEquals 0, Client.count()
... assertEquals 0, Client.count() passes, but ...
assertFalse Client.exists( cFound.id )
assertNull Client.get(cFoundId)开发者_如何学Go
... both fail. What could be the underlying reason? Thanks in advance.
Try to flush the context, in order to clean the caches:
cFound.delete(flush: true)
精彩评论