`
myway84
  • 浏览: 203615 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
文章分类
社区版块
存档分类
最新评论

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);
}




}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics