📄 schooldaohibernate.java.svn-base
字号:
/*
* 创建日期 2005-4-12
*/
package biz.bluesky.pts.service.dao.impl;
import java.util.List;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
import org.springframework.orm.ObjectRetrievalFailureException;
import biz.bluesky.pts.model.TSchool;
import biz.bluesky.pts.service.dao.ISchoolDAO;
public class SchoolDAOHibernate extends BaseDAOHibernate implements
ISchoolDAO {
//查询所有的学校
public List findSchools() {
return getHibernateTemplate().find("from TSchool");
}
//根据学校名称模糊查询学校
public List findSchhols(String schoolName) {
return getHibernateTemplate().find("from TSchool school where school.name like '%"+ schoolName + "%'");
}
//根据学校编号查询学校
public TSchool findSchool(int schoolId) {
TSchool school = (TSchool)getHibernateTemplate().get(TSchool.class,new Integer(schoolId));
if(school == null) {
throw new ObjectRetrievalFailureException(TSchool.class,new Integer(schoolId));
}
return school;
}
//根据学校名称查询学校
public TSchool findSchool(String schoolName) {
List list = getHibernateTemplate().find("from TSchool school where school.name='" + schoolName + "'");
if(list.size() < 1) {
return null;
}
else {
return (TSchool)list.get(0);
}
}
//根据学校Email查询学校
public TSchool findSchoolByEmail(String email) {
List list = getHibernateTemplate().find("from TSchool school where school.email='" + email + "'");
if(list.size() < 1) {
return null;
}
else {
return (TSchool)list.get(0);
}
}
//新增学校
public void saveSchool(TSchool school) {
getHibernateTemplate().saveOrUpdate(school);
getHibernateTemplate().flush();
}
//删除学校
public void removeSchool(int schoolId) {
TSchool school = findSchool(schoolId);
getHibernateTemplate().delete(school);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -