I am using Appfuse 2.0, Spring MVC, Hibernate.
I have two POJOs, Application (as in a job application or form) and Place. I
got this example straight out of the JPA Annotations Reference:
Application.java
@Entity
@Table(name = "applications")
private Set<Place> places;
@ManyToMany(
targetEntity=com.myco.myapp.model.Place.class,
cascade={CascadeType.ALL},
fetch = FetchType.EAGER
)
@JoinTable(
name="applicationsplaces",
[EMAIL PROTECTED](name="idApplication")},
[EMAIL PROTECTED](name="idPlace")}
)
public Set<Place> getPlaces(){
return places;
}
Place.java
@Entity
@Table(name = "places")
@ManyToMany(
cascade={CascadeType.ALL},
mappedBy="places",
targetEntity=Application.class
)
public Set<Application> getApplications() {
return applications;
}
When I create a new Application and associate Places my table,
applicationsplaces, is updated. But when I update an Application it is not
updated. Looking at the generated SQL, when I create a new Application the
following insert is done:
insert into applicationsplaces (idApplication, idPlace) values (?, ?)
No such insert is done when I update an Application. I've looked here,
Hibernate forums, FAQs, you name it. This seems like Hibernate 101 to me,
something that should be a no-brainer, even for a noob like me. But I can't
find the problem.
Anyone?
Thanks,
Bob
--
View this message in context:
http://www.nabble.com/Hibernate-ManyToMany-not-updating-collection-tf4428202s2369.html#a12632301
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]