package com.finiac.dao;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import com.finiac.model.FeeRegister;
public class FeeRegisterDAOImpl implements FeeRegisterDAO {
private HibernateTemplate hibernateTemplate;
public void setSessionFactory(SessionFactory sessionFactory){
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
@Override
public void addFeeRegister(FeeRegister feeRegister) {
hibernateTemplate.saveOrUpdate(feeRegister);
}
@Override
@SuppressWarnings("unchecked")
public List<FeeRegister> listAll() {
return hibernateTemplate.find("from FeeRegister");
}
@SuppressWarnings("unchecked")
@Override
public List<FeeRegister> selectByStudent(long admissionNo) {
return hibernateTemplate.find("from FeeRegister where admissionNo ="+admissionNo+" and isActive =1");
}
@SuppressWarnings("unchecked")
@Override
public List<FeeRegister> selectById(int id) {
return hibernateTemplate.find("from FeeRegister where id="+id + " and isActive =1");
}
@Override
public void updateFeeRegister(FeeRegister feeRegister) {
hibernateTemplate.update(feeRegister);
}
@SuppressWarnings("unchecked")
@Override
public List<FeeRegister> listFeeRegister() {
return hibernateTemplate.find("from FeeRegister where isActive =1 order by id");
}
@SuppressWarnings("unchecked")
@Override
public FeeRegister selectByAdmissionNo(long admissionNo) {
FeeRegister feeRegister= new FeeRegister();
List<FeeRegister> dailyList= hibernateTemplate.find("from FeeRegister where admissionNo="+admissionNo +" and isActive =1");
for(int i=0;i<dailyList.size();i++)
{
feeRegister = dailyList.get(i);
}
return feeRegister;
}
}