java - How to merge a @OneToMany relationship effectively? -


For example, I have the following two unit squares with one-to-many relationship:

  Public Class A implementation serializable {... @OnTomain (mapped = "A", cascade = cascade type.AL) Private list & lt; B & gt; Bs; ...} public class B serializable {... @ManyToOne applies a private A; ...}   

Suppose i have an example of a to a , and a.bs == [B1, b2, b3] . Now I want to remove the relationship from b1 , and add b4 so that a.bs == [b2, b3, b4] , and b1.a == blank .

I tried to do a.setBs (b2) after em.merge (a) , b3, b4) , But the result will be a.bs == [b1, b2, b3, b4] , unless I do not specify b1.setA (null) . However, if there is a complexity then a lot changes in a.bs , and if there are multiple relationships for the other unit sections in A orphanRemoval The = true setting is also not a solution, because I just want to set b1.a = null instead of b1 .

"post-text" itemprop = "text"

P> You can set the waterfall style to update on BS and a.bs.remove (b1); Session.update (a);

This trick does.

When you are asking ORM to update the cascade on the archive, the related value will be canceled when you archive.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -