01: package org.emforge.comment;
02:
03: import java.util.Collection;
04: import java.util.List;
05:
06: import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
07:
08: /**
09: * Implementation of Comment interface, which use database and hibernate to store comments
10: * @author imusihin
11: */
12: public class CommentDAOHinernateImpl extends HibernateDaoSupport {
13:
14: public void deleteComment(CommentDO comment) {
15: getHibernateTemplate().delete(comment);
16: }
17:
18: public CommentDO saveComment(CommentDO comment) {
19: getHibernateTemplate().saveOrUpdate(comment);
20: return comment;
21: }
22:
23: @SuppressWarnings("unchecked")
24: public Collection<CommentDO> getComments() {
25: return getHibernateTemplate().loadAll(CommentDO.class);
26: }
27:
28: public CommentDO getCommentById(Long id) {
29: return (CommentDO) getHibernateTemplate().get(CommentDO.class,
30: id);
31: }
32:
33: @SuppressWarnings("unchecked")
34: public Collection<CommentDO> getCommentsByPageName(String i_name) {
35: List<CommentDO> comments = getHibernateTemplate()
36: .findByNamedQuery("Comment.findCommentsByPageName",
37: i_name);
38: return comments;
39: }
40:
41: }
|