java - Saving bidirectional ManyToMany -
I have comments for two unit classes in the following elements
@Antie class A { @ A lot of people (Mapped = "A", Cascade = Cascade Type.AL) Private list & lt; B & gt; B; ..} @ Entity Class B {@ManyToMany (cascade = Cascade Type.Al) Private list & lt; A & gt; a; ..} If I store an example of class 'B', the relationships are stored in the database and in the class 'A' the correct subset of recipient B will return. However, if I change the list of BS in 'A', then what changes are not made in the database?
My question is, how can I do this so that the changes in the classroom are "cascading" for the other category?
Edit: I have mapped parameters I have tried various types of defining and defining a JoinTable (and column), but I am unable to find the right combination.
The smallest answer seems to be that you can not do it and it makes sense. Bidirectional many-to-many questions Must be a master on the one hand and the underlying participant is used to keep the changes in the table as the JPA will not maintain both sides of the association, you can eliminate a memory condition once stored in the database. Examples:
A1 = new A (); A2 = new A (); bb = new b (); a1.getB (add) (b ). B.getA () add (A2); If this situation is maintained If you can, you will end up with the following entries in the inserted table:
a1_id, b_id a2_id, b_id but on loading, how does the PPA know Is that you only know about A2 and not A1? And what about A2 should not know about B?
That is why you have to maintain the bidirectional union itself (and it is also impossible to remember the above version) and the JPA based only on one side of its position.
Comments
Post a Comment