Hi dear Cubans,
I’m facing a problem, I cannot figure a way out of it and I kindly ask you for support.
I have a several nested datasources that handle a couple of entities from a couple of related tables (please check attached ‘datasources-definition.png’ picture).
I generated a mixed browse-edit screen in Cuba editor for the “Person” entity. By default “personDs” and “personsDs” were created. I created manually all the nested datasources that can be seen in the picture. Please also check the attached pictures ‘person-table.png’ and ‘contact-table.png’ in order to understand the model.
The problem appears when adding a phone number to an existing person.
How I initialize the datasources
All I do in the ItemChangeListener of “personsDs” is call
personDs.setItem(reloadedItem);
and then load the “reloadedItem” 's properties in some frames.
How I update the “phoneNumberListDs”
So after creating the new “PhoneNumber” object I’m inserting it into “phoneNumberListDs” datasource like this:
Person editedItem = personDs.getItem();
Collection<PhoneNumber> phoneNumberCollection = phoneNumberFrameBox.getPhoneNumbersDs().getItems();
List<PhoneNumber> phoneNumberList = editedItem.getContact().getContactDetailList().get(0).getPhoneNumberList();
// .get(0) because for now the project decided to have only one ContactDetail in the list
for(PhoneNumber entity : phoneNumberCollection)
{
if(!phoneNumberList.contains(entity))
{
phoneNumberListDs.addItem(entity);
}
}
After doing so “personDs”, “contactDs”, “contactDetailListDs” and “phoneNumberListDs” datasources change their “modified” attribute to true, “phoneNumberListDs” has 1 item to create and the others have 1 item to update each while “postalAddressDs” remains untouched. Please check attached ‘personDs.png’, ‘contactDs.png’, etc in order to see the state of the datasources in debug mode right before triggering the commit.
THE PROBLEM
When I try to edit an existent entry and add another phone number unique constrain violation occurs. Please check ‘exception.txt’ file in order to see all the causes from within the exception object. The error appears while handling “Contact” table, the weird thing is that the framework uses “insert” method when trying to update the “Contact” entity instead of “update”. This info is available in the ‘exception.txt’ file.
The support would be really appreciated,
Andrei
exception.txt (2.5K)