使用SpringSide 3.1.4.3开发Web项目的全过程(上)
2009-09-24 00:00:00 来源:WEB开发网CommentDao.java如下:
package personal.youxia.dao;
import org.springside.modules.orm.hibernate.HibernateDao;
import personal.youxia.entity.Comment;
public class CommentDao extends HibernateDao<Comment, Long> {
}
可以看出,以上代码都从HibernateDao继承,得益于泛型支持,基本不需要编写一行代码。
编写Bussiness层代码,这一层,白衣使用的包名为service,而类名的后缀都是Manager,我就跟他学算了,懒得改了。
ArticleManager.java如下:
package personal.youxia.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.hibernate.HibernateDao;
import personal.youxia.dao.ArticleDao;
import personal.youxia.entity.Article;
public class ArticleManager extends EntityManager<Article, Long> {
@Autowired
private ArticleDao articleDao;
public void setArticleDao(ArticleDao articleDao) {
this.articleDao = articleDao;
}
@Override
protected HibernateDao<Article, Long> getEntityDao() {
// TODO Auto-generated method stub
return articleDao;
}
}
CommentManager.java如下:
package personal.youxia.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.hibernate.HibernateDao;
import personal.youxia.dao.CommentDao;
import personal.youxia.entity.Comment;
public class CommentManager extends EntityManager<Comment, Long> {
@Autowired
private CommentDao commentDao;
public void setCommentDao(CommentDao commentDao) {
this.commentDao = commentDao;
}
@Override
protected HibernateDao<Comment, Long> getEntityDao() {
// TODO Auto-generated method stub
return commentDao;
}
}
Tags:使用 SpringSide 开发
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接