|
You can do it in many ways (that is why I marked this bug as minor). If you are also removing a parent you can set delete cascade. If not you can put the code on the dao level: public void unsetReference(Entity parent) { Entity child = parent.getChild(); parent.setChild(null); entityManager.remove(child); }
You can prepare a "query" which will remove children without a parent (remember about index). This "query" can be executed in the @PostUpdate method or in a timer. You can even set a trigger in the db.
|