📄 provincedaoimpl.java
字号:
package com.sunny.test.dao.impl;
import java.util.List;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.sunny.test.dao.ProvinceDao;
import com.sunny.test.model.Province;
public class ProvinceDaoImpl extends HibernateDaoSupport implements ProvinceDao
{
public List findAll(int start,int offset) throws Exception
{
List all = null;
String hql = "from Province order by name";
Query q = this.getSession().createQuery(hql);
q.setFirstResult(start);
q.setMaxResults(offset);
all = q.list();
return all;
}
public int getAllCounts() throws Exception
{
int count=0;
String hql = "from Province";
Query q = super.getSession().createQuery(hql);
List list = q.list();
count = list.size();
return count;
}
public void save(Province province) throws Exception
{
getHibernateTemplate().saveOrUpdate(province);
}
public void delete(int id) throws Exception
{
getHibernateTemplate().delete(getProvince(id));
}
public Province getProvince(int id) throws Exception
{
return (Province)getHibernateTemplate().get(com.sunny.test.model.Province.class, id);
}
public List getProvinces() throws Exception
{
String hql = "from Province order by name";
List list = getHibernateTemplate().find(hql);
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -