Reputation: 143
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:
237
238
238
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?
Upvotes: 1
Views: 707
Reputation: 143
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
Upvotes: 0