I have a domain class called ApplicantFile
and I want to delete all the rows within this table at certain times. The following is what I am trying:
ApplicantFile.executeUpdate('DELETE FROM APPLICANT_FILE')
and I get this error:
APPLICANT_FILE is not mapped [DELETE FROM APPLICANT_FILE]
Here is my domain class:
class ApplicantFile {
String description
String path
static mapping = {
table schema:"EIUISSVF", name:"APPLICANT_FILE"
}
}
The executeQuery
is a domain method, you don't need to point to the table in your database, you need to point to your domain, in this case ApplicantFile
. And the DELETE
function in SQL doesn't need the *
.
Updating your statement:
ApplicantFile.executeUpdate("delete ApplicantFile")
For more examples: executeUpdate Grails.