首先看这张照片。这是我想在网上展示的结果! correct result
但是,我得到的结果与第一项相同 wrong one
例如,对于前5个结果,这是错误的。
Employee Id Crse Id Class Sec Class Mtg Nbr Strm Descr
0010054 006833 01 1 2163 POLYNESIAN DRUM ENSEMBLE
0010054 006833 01 1 2163 POLYNESIAN DRUM ENSEMBLE
0010846 002668 01 1 2163 SOCIAL WELFARE POLICY
0010846 002668 01 1 2163 SOCIAL WELFARE POLICY
0010846 002668 01 1 2163 SOCIAL WELFARE POLICY
结果应为
0010054 006833 01 1 2163 POLYNESIAN DRUM ENSEMBLE
0010054 006833 01 2 2163 POLYNESIAN DRUM ENSEMBLE
0010846 002668 01 1 2163 SOCIAL WELFARE POLICY
0010846 001672 01 1 2163 NON-GOV PROG DEVELOP
0010846 006423 01 1 2163 SOCIAL RESEARCH METHODS
我不知道为什么计算机只获得每个emplid的第一个值而不是整个emplid的每个值。
这些是我的代码。请帮我查看哪里出错了。谢谢!
控制器
private PsInstrClassDao psInstrClassDao;
private PsCurTermDao psCurTermDao;
public void setPsInstrClassDao(PsInstrClassDao psInstrClassDao) {
this.psInstrClassDao = psInstrClassDao;
}
public void setPsCurTermDao(PsCurTermDao psCurTermDao) {
this.psCurTermDao = psCurTermDao;
}
@RequestMapping(value = {""}, method = RequestMethod.GET)
public String getFacultyHome(Model model) {
List<PsInstrClass> facultyList = psInstrClassDao.list();
model.addAttribute("faculty", facultyList);
List<PsCurTerm> termList = psCurTermDao.list();
model.addAttribute("term", termList);
return "faculty";
}
PsInstrClassDao
@SuppressWarnings("unchecked")
@Transactional
public List<PsInstrClass> list() {
EntityManager em = PsEntityManagerFactoryListener.createEntityManager();
List<PsInstrClass> faculty = null;
try {
faculty = em.createQuery("select instr from PsInstrClass instr, PsCurTerm term "
+ "where instr.strm = term.strm").getResultList();
} catch (Exception e) {
logger.error("Error getting InstrClass list", e);
} finally {
if (em != null) {
em.close();
}
}
return faculty;
}
JSP
<table border="1">
<tr>
<td>Employee Id</td>
<td>Crse Id</td>
<td>Class Sec</td>
<td>Class Mtg Nbr</td>
<td>Strm</td>
<td>Descr</td>
</tr>
<c:forEach items="${faculty}" var="facultyItem">
<tr>
<td>${facultyItem.emplid}</td>
<td>${facultyItem.crseId}</td>
<td>${facultyItem.classSec}</td>
<td>${facultyItem.classMtg}</td>
<td>${facultyItem.strm}</td>
<td>${facultyItem.descr}</td>
</tr>
</c:forEach>