How to delete superclass entity whose subclass entity has been removed in Hibernate? -


there 2 entity classes , b, , instances a, b (a , b have same id). b subclass of ( b extends a). removed entity "b" database. then, saw "a" has not been deleted. s want. @ point of code, want remove "a" too. when entitymanager.remove(a) throws exception saying, detached entity can t removed. seems removing subclass entity makes superclass entity detached although superclass entity remains in database. can me remove instance a.

note: , b have same ids because when create b, automatically created same id ( rule of inheritance).

you should use session.delete(b). deletes both records database.

after having deleted b record native sql delete statement, have delete record accordingly native delete statement.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -