@SuppressWarnings("rawtypes") public JSONObject getAllItemsNameId() { List list = hib.getDataFromDatabase("FROM ItemNameId"); JSONObject obj = new JSONObject(); if (list != null && !list.isEmpty()) { HashMap<Long, String> hm = new HashMap<Long, String>(); for (int i = 0; i < list.size(); i++) { ItemNameId champ = (ItemNameId) list.get(i); hm.put(champ.getId(), champ.getName()); } obj.putAll(hm); } return obj; }
@SuppressWarnings("rawtypes") public JSONObject getItemByParselName(String name) { List list = hib.getDataFromDatabase("from ItemNameId where LOWER(name) LIKE LOWER('%" + name + "%')"); JSONObject obj = new JSONObject(); HashMap<Long, String> hm = new HashMap<Long, String>(); if (list != null && !list.isEmpty()) { for (int i = 0; i < list.size(); i++) { ItemNameId champ = (ItemNameId) list.get(i); hm.put(champ.getId(), champ.getName()); } obj.putAll(hm); return obj; } return null; }