accessorytabledao.java

来自「一个汽车售后服务站的典型的进销管理系统,B/S模式的」· Java 代码 · 共 78 行

JAVA
78
字号
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 + =
减小字号Ctrl + -
显示快捷键?