No, there is nothing out of the box that will delete an entity when you remove the last reference.
You could do that with a trigger, or a delete event listener. In both cases you have to write all the logic.
Question
I want to know if there is a way to configure hbm mapping to do something like this: when I delete the owner of a many-to-many relationship, after delete the children at the many-to-many table, delete also the entities in the other part of the relationship if all of them has no more children in the many-to-many table.
I tried to do something like this using the attribute cascade=all in side of the owner but this way delete always the other part, having other more registers in the many-to-many table or not.
Solution
No, there is nothing out of the box that will delete an entity when you remove the last reference.
You could do that with a trigger, or a delete event listener. In both cases you have to write all the logic.