Cascade delete on column references to ExternalFiles not work?

Even we set the cascade police to


on the column of a entity that has many-to-many relation to


when you delete one or few of files to a entity instance, you still see the fie in

External Files


Appropriate solution?


Were the standard screens for your entity created by Studio?

When you open the entity editor, you see the table of external files related to it.
There are two actions “Add” and “Remove”.
The actions are intended to link and unlink the instance of your entity to files. In the case of many_to_many relation, it means that rows of link-table are created/removed.

Try to remove an instance from the entity browser: all related files should also be removed.

For more information on delete policies, please see the following documentation:

Alright, thank you!

Still this problem.
Now the


will be cascade deleted by deletion of the entity referencing it.

But, when you delete the


, the file itself will not be removed from file system of OS.

Is this by design? Should I implement the file deletion in



'AfterDeleteEntityListener '



if want to purge this file?

when you delete the FileDescriptor, the file itself will not be removed from file system of OS. Is this by design?

Yes. You can erase files using FileStorageAPI.removeFile(). Also, there is the findOrphanFiles() operation in app-core.cuba:type=FileStorage JMX bean - it can show you files that have no corresponding descriptors in the database.