Update Entity Relationship via UPDATE .. SET Query
问题 I have two entities: class A { @OneToMany(mappedBy = "a") List<B> bs; // getter/ setter } class B { @ManyToOne A a; // getter/ setter } To delete one b, I first need to invalidate that relationship. "Traditionally" I would do something like that: A a = em.getReference(A.class, entityIdA) B b = em.getReference(B.class, entityIdB); a.getBs().remove(b); b.setA(null); em.remove(b); This is not very performant, if the List of a 's is getting large (a few hundreds in my case). I know I can also use