i am passing hibernate model class object type list but it prints as [Ljava.lang.Object;@1ec3adc.i am using spring mvc and tile hibernate.i want to pass "Subtab" type list.but it's passing "object" type list.
here's the code for returning the list :
DAOImpl :
public List<Subtab> listSubtab(int usertype){
List<Subtab> subtablist=sessionFactory.getCurrentSession().createQuery("SELECT s.maintab, s.description, s.ref from Subtab s,Authintication a where s.subtabId = a.subtab and a.usertype = '" + usertype + "'")
.list();
return subtablist;
}
controller :
List<Subtab> subtablist=(List<Subtab>)loginService.listSubtab(userExists);
model.addAttribute("SubtabsList",subtablist);
daO:
public List<Subtab> listSubtab(int usertype);
service :
public List<Subtab> listSubtab(int usertype);
serviceImpl :
@Transactional
public List<Subtab> listSubtab(int usertype) {
return loginDAO.listSubtab(usertype);
}
jsp:
<c:if test="${not empty SubtabsList}">
<c:forEach var="ob" items="${SubtabsList}">
<p>${ob}</p>
</c:forEach>
</c:if>
Please go through the Hibernate documentation: https://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/queryhql.html
If you would like to return Subtab objects then change your query to
Also please use bind variables in your query as you will avoid a lot of pitfalls in the future.