如何显示从休眠状态查询到引导程序表的结果?

我有一个项目,其中我使用了一个休眠的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表...。谢谢!


隔江千里
浏览 145回答 2
2回答

largeQ

你可以做这样的事情<tbody>&nbsp; &nbsp; <c:set var="count" value="1" scope="page" />&nbsp; &nbsp; &nbsp; &nbsp;<c:forEach var="userActiv" items="${acUsers}">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td class="center">${count}</td>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td>${userActiv[0]}</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td>${userActiv[1]}</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; <c:set var="count" value="${count + 1}" scope="page"/></c:forEach>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java