1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.in2.simpleBoard.dao.hibernate;
18
19 import java.util.Date;
20 import java.util.List;
21
22 import org.appfuse.dao.hibernate.GenericDaoHibernate;
23 import org.in2.simpleBoard.dao.BoardDao;
24 import org.in2.simpleBoard.model.Person;
25 import org.in2.simpleBoard.model.Board;
26 import org.in2.simpleBoard.model.Category;
27
28 public class BoardDaoHibernate extends GenericDaoHibernate<Board, Long> implements BoardDao {
29
30 public BoardDaoHibernate() {
31 super(Board.class);
32 }
33
34 public List<Board> findByUser(Person user) {
35 return findByUserId(user.getId());
36 }
37
38 public List<Board> findByUserId(Long userId) {
39 return getHibernateTemplate().find("from Board where idUser = ?", userId);
40 }
41
42 public List<Board> findByCategory(Category category) {
43 return findByUserId(category.getId());
44 }
45
46 public List<Board> findAllBoard(){
47 return getHibernateTemplate().find("from Board");
48 }
49
50 public List<Board> findByCategoryId(Long categoryId) {
51 return getHibernateTemplate().find("from Board where idCategory = ?", categoryId);
52 }
53
54 public List<Board> findByBoard(Board board) {
55 return findByUserId(board.getId());
56 }
57
58 public Board findByBoardId(Long boardId) {
59 return (Board) getHibernateTemplate().get(Board.class, boardId);
60 }
61
62 public List<Board> findByDate(Date date) {
63
64 return getHibernateTemplate().find("from Board where date = ?", "2007-01-01");
65 }
66
67 }