📄 accessorytabledao.java
字号:
package com.xfaccp.dao;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.xfaccp.adapter.DAOAdpater;
import com.xfaccp.base.BaseForm;
import com.xfaccp.form.AccessoryTable;
/**
* Data access object (DAO) for domain model class AccessoryTable.
*
* @see com.xfaccp.form.AccessoryTable
* @author MyEclipse Persistence Tools
*/
public class AccessoryTableDAO extends DAOAdpater{
public List findAllList() throws Exception {
return getHibernateTemplate().find("from com.xfaccp.form.AccessoryTable");
}
public List findById(Integer id)
throws Exception {
getHibernateTemplate().load(AccessoryTable.class, id);
return null;
}
public int getAccTableSize(String accName)throws Exception {
String hql="select count(*) from com.xfaccp.form.AccessoryTable";
if(accName!=null||!accName.equals(""))
{
hql+=" where accName like '%"+accName+"%'";
}
List list=this.getHibernateTemplate().find(hql);
int count=(Integer)list.get(0);
System.out.println(" list size"+list.get(0));
System.out.println("getOutputTableSize()");
return count;
}
public List getAccTableList(int size, int pageSize,String accName) throws Exception {
List list;
Session session = getSession();
String hql="from com.xfaccp.form.AccessoryTable";
if(accName!=null||!accName.equals(""))
{
hql+=" where accName like '%"+accName+"%'";
}
try {
Query q = session.createQuery(hql);
q.setFirstResult(size);
q.setMaxResults(pageSize);
list = q.list();
System.out.println("getOutputTableList()");
} finally{
session.close();
}
return list;
}
public void load(BaseForm form) throws Exception
{
System.out.println("__________________");
AccessoryTable acc = (AccessoryTable)form;
getHibernateTemplate().load(acc,acc.getId());
//将子对象集拿到本地初始化
getHibernateTemplate().initialize(acc.getStockAccessoryTables());
}
/*public List findBySql() throws Exception{
return getHibernateTemplate().find("from com.xfaccp.form.CodeTable");
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -