我有一个项目,其中我使用了休眠弹簧启动,我想在一个查询中连接两个表,并在引导表中显示结果。我进行了查询并取得了结果,但是它在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表中。...谢谢!
答案 0 :(得分:0)
您可以这样做
<tbody>
<c:set var="count" value="1" scope="page" />
<c:forEach var="userActiv" items="${acUsers}">
<tr>
<td class="center">${count}</td>
<td>${userActiv[0]}</td>
<td>${userActiv[1]}</td>
</tr>
<c:set var="count" value="${count + 1}" scope="page"/>
</c:forEach>
答案 1 :(得分:0)
我找到了解决方案,只需更改:
<button class="selector" data-city="bangalore">Bangalore</button>
<button class="selector" data-city="mumbai">Mumbai</button>
<div id="openweathermap-widget-14"></div>