First of all, a simple example that shows this error can occur (Tapestry 5.0.17):
Imagine the following:
1. A page that shows objects to be edited inside of a Grid (EditDomains)
- An "Edit Link" inside of the grid table that will link to another page that allows editing of the object. The "Edit Link" passes the whole object to the Edit Page.
2. The Edit Page receives the edited object and saves it.
EditDomains.tml
EditDomains.java
1
2 @InjectPage
3 private EditDomain editDomain;
4
5 EditDomain onActionFromEdit(Domain domain)
6 {
7 editDomain.setDomain(domain);
8 return editDomain;
9 }
EditDomain.tml
EditDomain.java
1
2 private void onSelectedFromAddDomain() {
3
4
5 session.updateOrUpdate(domain);
org.apache.tapestry5.runtime.ComponentEventException a different object with the same identifier value was already associated with the session: [tm.framework.entities.Domain#6]
The Solution:
1
2 Domain temp = (Domain)session.merge(domain);
3 session.update(temp);