EquipmentDAOImpl

package com.huaweisymantec.rmc.core.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.huaweisymantec.rmc.core.dao.EquipmentDAO;
import com.huaweisymantec.rmc.core.domain.Equipment;

@Component
public class EquipmentDAOImpl implements EquipmentDAO {

private HibernateTemplate ht;

public HibernateTemplate getHt() {
return ht;
}
@Resource
public void setHt(HibernateTemplate ht) {
this.ht = ht;
}


public void saveEquipment(Equipment equip) {

ht.save(equip);

}

public void deleteEquipment(String ESN) {

ht.delete(findEquipment(ESN));
}

public void updateEquipment(Equipment equip) {

ht.update(equip);
}

public Equipment findEquipment(String ESN) {
List list=ht.find("from Equipment where esn=?",ESN);
if(list.size()>0)
{
return (Equipment)list.get(0);
}
else
{
return null;
}
}

public boolean isExitEquipment(String ESN) {
List list=ht.find("from Equipment  where esn=?",ESN);

if(list.size()>0)
return true;
else
return false;
}

public Equipment getEquipmentByESN(String ESN) {
List<Equipment> equip = ht.find("from Equipment  where esn='" + ESN+ "'");
return equip.get(0);
}




}

你可能感兴趣的:(DAO,orm)