I have one project where i use a hibernate spring boot and i want to connect tow tables in one query and show the results in bootstrap table. i made the query and i take the results but it is in List<Oject[]>
and i need it in List<MyClass>
i think. So can someone help me how to do it...How to put query results in bootstrap table..?
The query is:
TableInfoDAO.java
CriteriaBuilder builder = getCurrentSession().getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = builder.createQuery(Object[].class);
Root<DocumentBean> rootDept = criteriaQuery.from(DocumentBean.class);
Root<TableInfoBean> rootEmp = criteriaQuery.from(TableInfoBean.class);
criteriaQuery.multiselect(rootDept,rootEmp);
criteriaQuery.where(builder.equal(rootDept.get("user_id"), rootEmp.get("id")));
Query<Object[]> query = getCurrentSession().createQuery(criteriaQuery);
List<Object[]> resl = query.getResultList();
for (Object[] objects : resl) {
DocumentBean employee=(DocumentBean)objects[0];
TableInfoBean department=(TableInfoBean)objects[1];
System.out.println("EMP NAME="+department.getName()+"\t DEPT NAME="+employee.getNote());
}
acUsers = (List<TableInfoBean>) (Object) resl;
And the tableInfo.jsp
<tbody>
<c:set var="count" value="1" scope="page" />
<c:forEach var="userActiv" items="${acUsers}">
<tr>
<td class="center">${count}</td>
<td>${userActiv.name}</td>
<td>${userActiv.lastname}</td>
</tr>
<c:set var="count" value="${count + 1}" scope="page"/>
</c:forEach>
How to get results to the Bootstrap table....Thanks !
I found the solution, just change :
for (Object[] objects : result) {
DocumentBean documentInfo=(DocumentBean)objects[0];
TableInfoBean userInfo=(TableInfoBean)objects[1];
System.out.println("Kelner="+userInfo.getName()+"\t Masa="+documentInfo.getNote());
TableInfoBean zaedno = new TableInfoBean();
zaedno.setLastname(documentInfo.getNote());
zaedno.setName(userInfo.getName());
userInformation.add(zaedno);
}