i want to ask some question, how to get specific value from list and add to another list, lets say i have list (this is cust list from hibernate DAO) like:
[["marketplace","001-002-003"],["insurance","142-523-132"],["car purchase","982349824"]]
i just want to get a value of "marketplace","insurance", and "car purchase" from that list and add to new list called "bu"
here is my code
public @ResponseBody String findBU(@RequestBody AllCustomerHist customer){
BigDecimal id= customer.getId();
String message;
List<String> bu= new ArrayList<>();
int i;
System.out.println("ID = "+id);
List<AllCustomerHist> cust = allCustomerHistService.findBU(id);
for (i=0; i<cust.size(); i++){
System.out.println("iteration = "+i);
// stumbled here //
}
JSONObject json = new JSONObject();
json.put("id", id);
json.put("BU", bu);
message = json.toString();
return message;
}
this is my AllCustomerHistDaoImpl class
//release 1.3
@SuppressWarnings("unchecked")
public List<AllCustomerHist> findBU(BigDecimal adpId) {
// TODO cek kodingan
Criteria criteria = getSession().createCriteria(AllCustomerHist.class)
.setProjection(Projections.projectionList()
.add(Projections.property("srctable"), "srctable")
.add(Projections.property("customerId"), "customerId"))
.add(Restrictions.eq("adpId", adpId));
return (List<AllCustomerHist>)criteria.list();
}
Notice that AllCustomerHist is an entity class to define the table in hibernate
thank you for your helps :D
AllCustomerHist? More importantly, why do assume we would know?