Please help me on this:
The problem presented before happens because when I try to persist the same object using a list it will create many rows in the database:
Code:
for(T entity : entities){
entity = (T) getSession().merge(entity);
}
This has a different behaviour of persisting it x times:
Code:
entity = (T) getSession().merge(entity);
entity = (T) getSession().merge(entity);
...
This will only produce one row.
Using the list, I saw that after executing the merge the entity does not receive the return of the merge, and that's why it persists the entity many times. But why does this happen?