I think there is only a programmatic way of this with something like
Code:
delete from A a where
a.b = :b
Many-to-one does not support all delete orphan as a cascade style.
bora.erbas wrote:
Hi,
I need some guidance as to how this should be done. For example I have a unidirectional many-to-one association from Class A to Class B.
Every A instance has a B instance, and a B instance may be referred by many A instances...However Class B does not know about Class A. Hence unidirectional...
What I want to do is this: whenever a row in the database corresponding to a B instance is removed, I need the A instance rows in the database which refer to the deleted B instance are removed as well.
This is sort of a parent/child relationship where the parent does not know the children, and the children should be removed when the parent is removed...
Can this be done via Hbn cascading, or should be done programatically? Maybe I am confused too much, I don't know.
Hibernate version: 3.1