-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: many-to-many collection changes not persisting
PostPosted: Mon Jan 08, 2007 12:53 am 
Newbie

Joined: Mon Apr 25, 2005 4:34 pm
Posts: 5
Hibernate version: 3.2.1

Mapping documents:

Code:
@ManyToMany(targetEntity = Van.class, cascade={CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
@JoinTable(name = "employees_vans", joinColumns = @JoinColumn(name="employee_id", referencedColumnName="employee_id"), inverseJoinColumns= @JoinColumn(name="van_id", referencedColumnName="van_id"))
public List<Van> getVans() {
    return vans;
}


Code:
@ManyToMany(targetEntity = Employee.class, mappedBy = "vans", cascade={CascadeType.PERSIST, CascadeType.MERGE})
public List<Employee> getEmployees() {
    return employees;
}


Name and version of the database you are using: Derby 10.1.3.1

I am having trouble with the above many-to-many association.

When I remove a van from a employee using the following...

Code:
employee.getVans().remove(van);
van.getEmployees().remove(employee);


...then save the change with the following, the changes to the to collections are not flushed the database. (I am commting the transaction and still no flush.)

Code:
session.saveOrUpdate(employee);


But when I change a property of the Employee class in addition to the collections, then the changes to the to collections are flushed the database.

Code:
employee.setName("Change Name");


What could cause hibernate to ignore the changes to the collections in the example where I did not change the name property?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.