
January 11th, 2013, 05:46 PM
|
|
Contributing User
|
|
Join Date: Sep 2005
Posts: 385
  
Time spent in forums: 4 Days 20 h 7 m 56 sec
Reputation Power: 9
|
|
|
Hibernate/spring mvc database results not returning correctly
Hi,
I am a little rusty haven't done this in almost a year. But, I am just returning a list of objects from a database result, the number of results are returning correct, however, it's just giving me a repeat of the first result when I display my jsp.
Can you please check my work below and help me spot where the problem is?
Thanks so much
Here is my database query:
Code:
public List<Checklist[]> getChecklist(String employid) throws PortletException {
List<Checklist[]> result = null;
if(employid == null){
throw new PortletException("Programming error: getChecklist called with null parameter");
}
try{
result = getHibernateTemplate().find("from Checklist where employid = '" + employid + "' order by requirement");
//size here is outputting correctly
System.out.println("Size:" + result.size());
}catch (HibernateException ex) {
throw convertHibernateAccessException(ex);
}
return result;
}
Here is the relevant part of the Controller:
Code:
...
@SuppressWarnings("unchecked")
@RequestMapping("VIEW")
public String mainView(Model model, RenderRequest request)
throws PortletException {
List<Checklist[]> checklists;
//calls function from above
checklists = checklistStore.getChecklist(userid);
model.addAttribute("checklists",checklists);
return "view";
}
Here is my view.jsp:
Code:
<c:forEach items="${checklists}" var="item" varStatus="status">
${item.requirement}
</c:forEach>
Here is my object:
Code:
public class Checklist implements Serializable{
private static final long serialVersionUID = 1L;
private String employid;
private String lastname;
private String firstname;
private String requirement;
private String status;
private String office;
public String getEmployid(){
return employid;
}
public void setEmployid(String employid){
this.employid = employid;
}
public String getLastname(){
return lastname;
}
public void setLastname(String lastname){
this.lastname = lastname;
}
public String getFirstname(){
return firstname;
}
public void setFirstname(String firstname){
this.firstname = firstname;
}
public String getRequirement(){
return requirement;
}
public void setRequirement(String requirement){
this.requirement = requirement;
}
public String getStatus(){
return status;
}
public void setStatus(String status){
this.status = status;
}
public String getOffice(){
return office;
}
public void setOffice(String office){
this.office = office;
}
}
|