我有一个项目,其中我使用了一个休眠的Spring Boot,我想在一个查询中连接两个表,并在bootstrap表中显示结果。我提出了查询,我接受了结果,但是它在List<Oject[]>里面,List<MyClass>我认为我需要它。那么有人可以帮我怎么做...如何将查询结果放入引导表..?查询是:
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;
还有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>
如何获得结果到Bootstrap表...。谢谢!
largeQ
相关分类