A datasource changes are not propagated to the database.

Hi all, I have a screen with a table and a groupDatasource associated with it, in a method of screen controller, I get the datasource an element (Entity = datasource.getItem ()) and modify properties (Entity.setXXX()) and these changes if reflect on the screen, but when I select another record in the table changes disappear and return to their origin. they are not propagating the changes to the database, why?
Thanks and regards.
P.D. In the groupDatasource Allow commit is checked.

Datasources save changes to the database (actually, by sending them to the middleware) when the datasource.commit() or the whole DsContext.commit() method is invoked. It is usually done when a user presses OK on the screen.
When you change entities contained in a datasource, the datasource accumulates the changes and is able to save them on commit. So your situation, when changed records revert back when you go to another record, is not normal. Can you provide the source code of your screen controller?

Hi Konstantin, the process is launched by pressing a button on the screen:

public void onBtn_VolverComunicarClick (Component source) {
        List <ComunicacionFtp> listaComunicacionActualizada = new ArrayList <ComunicacionFtp> ();
        // Walk the datasource selecting the failed communications
        List <ComunicacionFtp> items = comunicacionFtpsDs.getItems().stream().filter(elemento->!elemento.getComunicado()).collect(Collectors.toList());
        // Get a List with communications that have been updated
        listaComunicacionActualizada = actualizarComunicacionFtpService.inicio (items);
        // Update the datasource with returned communication
        for (ComunicacionFtp x: listaComunicacionActualizada) {
            comunicacionFtpsDs.updateItem (x);
        }
        comunicacionFtpsDs.getDsContext () commit ().;
    }
  1. I get the entities that I want to manipulate
  2. call to a service that runs through the list and modify some properties of each entity, returns the list with the modified entities.
  3. I walk the list and update the datasource with each element
  4. I do commit to datasource
    Thanks.

Hi Jose Alberto,
It should work - see the demo project attached.
If you need my further help with this issue, try to make my demo fail and let me know.

update-ds.zip (35.3K)

Konstantin your example works ok, I also tested with one datasource and the result has been ok but my application still does not send the data to the database. To explain it better I attached several pictures and I’ll explain:

  1. Imagen1 -> this is the general screen, the grid on the right has a datasource that is filtered by the datasource grid of the left
  2. Imagen2 -> the datasource grid of the right
  3. Imagen3 -> pressing the “Comunicar” button service (image5) that updates the Start field and the End of the entities is released, it ends well as the grid on the right changes are reflected.
  4. Imagen4 -> check it in the code with the debugger that the datasource is updated after the commit () and is ok. The display reflects the update correctly
  5. Imagen5 -> If pulse in a record other than the grid on the left, returning to the previous record in the grid on the left, the Start and End fields right grid have returned to their origin.
    It has to be something obvious, but I do not see, I appreciate a little light.
    Greetings.

imagen1

imagen2

imagen3

imagen4

imagen5

imagen6

  • Look to the database at the moment of Imagen4 - does it contain changes?
  • Set a breakpoint to the DataManagerBean.commit(CommitContext) method - you will see what data and when is committed from the client.

The database does not have the modification, in fact in any way the modification reaches the database. I have set the breakpoint and step by step attached pictures, it is curious that the internal commit retrun false, but the last image after having returned false commited, the datasource updated contains the modified field but the field “modified” is false. It’s like he does not know it has updated data.

image1

image2

image3

I’m afraid I can help you only if you reproduce the issue on my test project. Screenshots are not that useful for debugging.

Hi, I spent a few days holiday and can not send the project zip, I attached for review.
Greetings and thanks.

ConnectOctopus.zip (10.8M)

Hi Jose Alberto,
Unfortunately, I cannot even compile your project because it requires file-based dependencies which I don’t have.
And let me clarify one thing: normally, we don’t review or fix real projects here on the free support forum. Please reproduce your problem on my sample project which I attached earlier, or create your own with minimum code and dependencies.