1

In my rapidclipse 4.0 project, I have to read data out of a database view, while saving manual entered data. The readed value should then be included into the data to be saved.

My problem is, that this works fine, only onetime/ the first save. If I save a second time, the value is not updated.

In the save-button click event I placed following code:

private void cmdSave_buttonClick(final Button.ClickEvent event) {
    try {
        this.txtDmvTable.setValue("T_supplier");

        final int i = 1;
        VSuppliersNewId vsni = new VSuppliersNewId();
        vsni = new VSuppliersNewIdDAO().find(i);

        this.txtDmvCol00.setValue(vsni.getNewSupId().toString());

        this.fieldGroup.save();
    }
    catch(final Exception e) {
        e.printStackTrace();
        Notification.show("Do isch was falsch",
                e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
    }
}

The following lines did exactly what expected, but only one time:

final int i = 1;
VSuppliersNewId vsni = new VSuppliersNewId();
vsni = new VSuppliersNewIdDAO().find(i);

this.txtDmvCol00.setValue(vsni.getNewSupId().toString());

The view VSuppliersNewId will always give back only one uptodate value.
For example:

  • My view gives back the highest value out of a table field.
  • Lets asume in the first round it gives back the number 237
  • After saving my data, the view will give back perhaps 238
  • If I read this direct by sql in the database I get back 238
  • but by the above code it still persists the 237

I assume, that the whole code chain from database has to be refreshed/ reloaded, but it didn't.

How to change/enhance my code to get the expected result? What did I wrong?

cfrick
  • 35,203
  • 6
  • 56
  • 68
Schwabenheinz
  • 133
  • 1
  • 11
  • I tried also to set persistence,xml the property to none: ``` without success. And I tried to set following entry in th entity: ``@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONE)` and @cacheable(false) also without success... – Schwabenheinz May 04 '19 at 13:58

1 Answers1

0

I found the solution by myself There are several steps which I did.

1) opend my entity and set cacheable = false
2) opend persistence.xml and set following parameters:

<property name="hibernate.cache.use_query_cache" value="false" />
<property name="xdev.queryCache.mode" value="ENABLE_SELECTIVE" />
<property name="hibernate.cache.use_second_level_cache" value="false" />

I used following code to get the table refresh done:

 private void cmdSave_buttonClick(final Button.ClickEvent event) {
     try
     {
        this.txtDmvTable.setValue("T_supplier");

        final int i = 1;            
PersistenceUtils.getEntityManager(manOKMContacts.class).unwrap(SessionFactory.class);

        VSuppliersNewId vsni = new VSuppliersNewId();
        vsni = new VSuppliersNewIdDAO().find(i);

        this.txtDmvCol00.clear();
        this.txtDmvCol00.setValue(vsni.getNewSupId().toString());

        this.fieldGroup.save();

        this.table.getBeanContainerDataSource().removeAll();
        this.table.getBeanContainerDataSource().addAll(new OkmDbMetadataValueDAO().findAllContacts());
        this.table.getBeanContainerDataSource().refresh();

        this.table.setSortContainerPropertyId("DmvCol00");
        this.table.sort();

                     }
     catch(final Exception e)
     {
      Notification.show("Do isch was falsch", e.getMessage(), Notification.Type.ERROR_MESSAGE);
     }

}

Hope this will help others

Schwabenheinz
  • 133
  • 1
  • 11