Основная причина
org.hibernate.exception.SQLGrammarException: не удалось выполнить запрос
Исключение
org.springframework.web.util.NestedServletException: сбой обработки запроса;вложенное исключение: org.hibernate.exception.SQLGrammarException: не удалось выполнить запрос
У меня есть dao
public List<Book> task3() {
Session session = this.sessionFactory.getCurrentSession();
String sql = "SELECT books.genre, COUNT(*) AS counter FROM books GROUP BY genre";
SQLQuery query= session.createSQLQuery(sql);
query.addEntity(Book.class);
List<Book> authorList1 = query.list();
return authorList1;
}
и контроллер
@RequestMapping(value = "/task3", method = RequestMethod.GET)
public String task3(Model model){
model.addAttribute("task3", this.bookService.task3());
return "task3";
}
Как Corect выводит эту информацию наjsp?
Меня так судили, но не так:
<c:if test="${!empty task3}">
<table class="tg">
<tr>
<th width="120">name</th>
<th width="120">genre</th>
<th width="120">rating</th>
<th width="120">published</th>
</tr>
<c:forEach items="${task3}" var="author">
<tr>
<td>${author.name}</td>
<td>${author.genre}</td>
<td>${author.rating}</td>
<td>${author.published}</td>
</tr>
</c:forEach>
</table>
</c:if>
enter code here
enter code here