How can I join list and compare with another list
List list = new ArrayList();
List mList = getGroupById(date, id); // have 2 data
List tList = getSummary(date, id); // have 5 data
tList.addAll(create(tlog));
for (Rev m : (List<Rev>) mList) {
Detail x = new Detail();
for (Object[] s : (List<Object[]>) tList) {
if (s[1].toString().equals(m.getMid())) {
System.out.println("dddd " + s[1]);
}
}
}
Query
public List create(List<Alog> tlog) {
List list = new ArrayList<>();
...
Detail x = new Detail();
...
x.setAbc(abc);
list.add(x);
return list;
}
public List getSummary(String date, String id)
{
StringBuilder bf = new StringBuilder();
bf.append("SELECT ");
bf.append("'ABC', ");
...
return em.createQuery(bf.toString())
.setParameter("date", date, TemporalType.DATE)
.setParameter("id", id)
.getResultList();
}
Error
cannot be cast to [Ljava.lang.Object;
at com.rh.app.service.reader.SummaryReader.read(SummaryReader.java:182)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) cannot be cast to [Ljava.lang.Object;
at com.rh.app.service.reader.SummaryReader.read(SummaryReader.java:182)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
pointed to
for (Object[] s : (List<Object[]>) tList)