Page 1 of 1
Update and Delete always Failed
PostPosted:Sun Aug 12, 2018 10:16 am
by mamad
hi guys
i want to update and delete some data from database in a gwt-based class according to code below :
(i copy and paste all codes from documentations)
Code: Select all // Update value
security.setName("some name changed");
metadataService.updateValue(security.restoreToMap(), new AsyncCallback<Object>() {
@Override
public void onSuccess(Object result) {
}
@Override
public void onFailure(Throwable caught) {
}
});
// Delete value
metadataService.deleteValue(security.restoreToMap(), new AsyncCallback<Object>() {
@Override
public void onSuccess(Object result) {
}
@Override
public void onFailure(Throwable caught) {
}
});
}
Problem is that always onFailure method calls(i initialize tables correctly before ) and nothing delete or update from database.
why is this for ?
thanks in advance
Re: Update and Delete always Failed
PostPosted:Sun Aug 12, 2018 5:10 pm
by jllort
Seems you are modifying the source code, no? Are you using the OpenKM development environment for it. Anyway, first step is to check if your code really is executed. I suggest some breakpoint at the Servlet side and some Window.alert("test") from GWT side to ensure really the code is executed.
Re: Update and Delete always Failed
PostPosted:Mon Aug 13, 2018 3:55 am
by mamad
yeah im modifying source code and also using ova and my code execute well (i use an alert in OnFailure() method and this alert always appear when i try to update a row of table)
i just copy and paste all codes from documentations (even queries for initialize database) from link below.
https://docs.openkm.com/kcenter/view/ok ... gwt-).html
Insert and Select codes works properly but Delete and Update always failed.
Are you sure you test delete and update parts of your codes ???
Re: Update and Delete always Failed
PostPosted:Tue Aug 14, 2018 1:40 pm
by jllort
You might debug in what conditions arrive data in the servlet and how comes into until is executed. When you are talking about an error, do you refer to the data is not removed from the database or is raised some exception?
Re: Update and Delete always Failed
PostPosted:Wed Aug 15, 2018 4:37 am
by mamad
I mean data is not removed or updated in database and it does not throw any exception.
Actually onFailure() method always called when i try to update or delete.
Please consider that i am talking about the pure source code in documentation (i don't change any line of that and just add a window.alert() to onFailure method to ensure it call every time i try to update or delete)
Also i initialize database(OKM_DB_METADATA_TYPE and OKM_DB_METADATA_VALUE tables) by executing queries in documentations.
Do you test the update and delete methods yourself to ensure they works properly ???
Re: Update and Delete always Failed
PostPosted:Thu Aug 16, 2018 2:18 pm
by jllort
If you suspect the code is wrong, you should debug it and report the bug. The code was working an tested when was created. These sections of code come from professional version and we do not longer use it, really in the professional version we consider as deprecated and moved to a more specific solution when needed to work with custom tables rather than using these based on metadata.
Anyway should be working, an in case they are not working you should follow the code in order to discover if the method is doing what expected or not, at the end each method ends with SQL query to be executed, if the query is not right then should consider if it's an error with the code of how are you using it or how tables are registered.
Re: Update and Delete always Failed
PostPosted:Tue Sep 25, 2018 5:52 am
by mamad
Hi,
Finally i found the solution for this problem.
The reason of failing update and delete queries was the "Safe Mode" in MySQL Workbench.
Here is the steps to disable it:
https://stackoverflow.com/a/14232119
Re: Update and Delete always Failed
PostPosted:Wed Sep 26, 2018 6:09 pm
by jllort
We will take note about it, I supposed "safe mode" only affected Work Bench connection, not the other database connection.