Avatar of Perplexity
Perplexity

asked on 

Hibernate - how does it handle changes in a ManyToMany relationship?

Lets say that I am creating some EJB entity beans that are persisted via Hibernate.  One bean can contain a list of the other type of bean - bean.getList() and bean.setList(theList).  (the list contains a list of a different object.)  The relationship between the two tables that the entities map to, in a third table, which just has the ID's from the other two.  (Basically, this allows for a many to many relationship.)

If I add or remove things from that list on a web page, how does Hibernate handle updating the table?  Since things could be both added and removed, I am curious how Hibernate handles this behind the scenes?  Does it first determine what it needs to change, and then updates those things?  Would it handle something like that correctly?
Java EE

Avatar of undefined
Last Comment
Perplexity

8/22/2022 - Mon