Plugins You can find out about all the publicly available Grails plugins.

Logical Delete Plugin

1 vote
compile ":logical-delete:0.1"

 Documentation  Source  Issues


Allows you to do a logical deletion of domain classes


grails install-plugin logical-delete


This plugin allows you to do a logical deletion of the domain classes. The main intention of the plugin is to handle cases when certain entities cannot be physically removed from the database.

How it works:

Most of the work is done using AST transformations. For the desired class a new boolean property is added: deleted. The GORM method delete is modified to avoid the physical removal and just change the value of the deleted property. In addition to the AST transformations, an Hibernate filter is added to make the exclusion of the deleted entities transparent.

How to use:

To provide logical deletion to a domain class you just need to add the @LogicalDelete annotation to it.

class User {
   String lastName
   String firstName
   String nickName

To make a logical removal you just need to use the GORM method delete .


If you want to force a physical deletion to an annotated class, you have to add the physical parameter in true to the delete method:

user.delete(physical: true)