Hibernate version:3.1
Name and version of the database you are using:
mysql 5
i have 2 entity with @ManyToMany reference:
Quote:
@Entity
@Table(name = "tblCart")
public class Cart extends IDEntity {
private Collection<File> items = new ArrayList<File>();
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
public Collection<File> getItems() {
return items;
}
....
@Transient
public void removeItem(File file) {
items.remove(file);
}
File doesn't have reference to Cart.
when i performs:
Quote:
Cart cart = ..retrieving..
File file = ..retrieving..
...
session.flush();
session.clear();
session.beginTransaction();
cart.removeItem(file);
session.merge(cart);
session.getTransaction().commit();
it doesnt change db... in log i see:
The generated SQL (show_sql=true):
Hibernate: delete from tblCart_tblFiles where tblCart_id=?
Hibernate: insert into tblCart_tblFiles (tblCart_id, items_id) values (?, ?)
WHY?? what can i do to avoid this?