帮忙看个Hibernate题目
指出一下代码哪里错误使用了Hibernate。
背景简介:Board是一个实体类,id是它的主键,name和description是他的两个属性。BoardDao是Board实体的数据访问对象,BoardBo是业务对象,用户提交变更Board对象的请求,由Struts的BoardAction接收,调用BoardBo处理。HibernateUtil.currentSession()用于返回当前请求的Session对象。
1. //数据访问层代码:BoardDao.java
2. public Board loadBoard(Long id) {
3. Session session = HibernateUtil.currentSession();
4. return session.load(Board.class, id);
5. }
6. public void updateBoard(Board board) {
7. Session session = HibernateUtil.currentSession();
8. session.update(board);
9. }
10.
11. //业务对象层代码:BoardBo.java
12. private BoardDao boardDao;
13. public void updateBoard(Long id, String name, String description) {
14. Board board = boardDao.loadBoard(id);
15. board.setName(name);
16. board.setDescription(description);
17. boardDao.updateBoard(board);
18. }
19.
20. //Web控制器代码:BoardAction.java
21. private BoardBo BoardBo;
22. public ActionForward execute(
23. ActionMapping mapping,
24. ActionForm form,
25. HttpServletRequest request,
26. HttpServletResponse response) throws Exception {
27. String id = request.getParameter("id");
28. String name = request.getParameter("name");
29. String description = request.getParameter("description");
30. boardBo.updateBoard(id, name, description);
31. return mapping.findForward("update-success");
32. }