I have two entity classes A and B that exist in a bidirectional one-to-many relationship respectively.
A.java:
@On
JPA doesn't manage relations for you, so while you have called remove on b, a still has a reference to it. Since the reference has a cascade persist/merge set on it, it causes b to be resurrected in the context, undoing the remove.
You must maintain references to keep your model in sync with what you want in the database. It is good practice to null out references to objects you are removing and set back pointers unless you are sure you can deal with potential inconsistencies such as this.