Я хотел бы знать, как предотвратить повторяющиеся вставки при выполнении вызова RPC из клиента Android, подключенного к ядру приложения.Ниже приведен мой код и то, что я пробовал на бэкэнде, но когда я это делаю, я получаю «Внутреннюю ошибку сервера».
public void createentity(userentity e) {
PersistenceManager pm = PMF.get().getPersistenceManager();
//to go through the records and and check for duplicates
Query q = pm.newQuery("select from" + userentity.class + "where Country=='" + e.getCCNumber() + "'");
List < userentity > s = (List < userentity > ) q.execute();
//if the size is equal to to null means there is no duplicate
if (s.size() == 0) {
//insert the value
try {
pm.makePersistent(e);
} finally {
pm.close();
}
}
}