cdtypedaoimpl.java

来自「用jsf实现cd商店的程序」· Java 代码 · 共 54 行

JAVA
54
字号
package com.tangjun.data.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.tangjun.data.ICDTypeDao;
import com.tangjun.web.pojo.CD;
import com.tangjun.web.pojo.CDType;

public class CDTypeDaoImpl extends HibernateDaoSupport implements ICDTypeDao
{

	public boolean addType(CDType cdType)
	{
		this.getHibernateTemplate().save(cdType);
		return false;
	}

	public boolean delType(Integer id)
	{
		CDType cdType=(CDType)this.getHibernateTemplate().load(CDType.class,id);
		this.getHibernateTemplate().delete(cdType);
		return false;
	}

	public CDType findTypeById(Integer id)
	{
		String hql="from CDType ct where id=?";		
		List types=this.getHibernateTemplate().find(hql,id);
		if(types.size()==1)
			return (CDType)types.get(0);
		return null;
	}

	public List getAllType()
	{
		String hql="from CDType cdt";
		return this.getHibernateTemplate().find(hql);
	}

	public boolean updateType(CDType cdType)
	{
		// TODO 自动生成方法存根
		return false;
	}
	
	public List getAllTypes()
	{
		String hql="select cdt.typeName from CDType as cdt";
		return this.getHibernateTemplate().find(hql);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?