Q:

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)

... both fail. What could be the underlying reason?
Thanks in advance.

A:

Try to flush the context, in order to clean the caches:
cFound.delete(flush: true)

