package com.palmnest.dao.estateserve.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.palmnest.dao.estateserve.EmigSettleDao;
import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.model.emig.EmigrationSettle;

@Repository("emigSettleDao")
public class EmigSettleDaoImpl extends GenericDaoHibernate<EmigrationSettle, Integer> implements EmigSettleDao {

	public EmigSettleDaoImpl() {
		super(EmigrationSettle.class);
	}

	@Override
	public int delEmigSettleByEmigId(String emigId) throws Exception {
		StringBuilder sql = new StringBuilder("delete from EmigrationSettle where enterId=? ");
		return this.getSession().createQuery(sql.toString()).setString(0, emigId).executeUpdate();
	}

	@Override
	public EmigrationSettle getEmigSettleByEmigId(String emigId)
			throws Exception {
		StringBuilder sql = new StringBuilder("EmigrationSettle where enterId=? ");
		List<EmigrationSettle> list = this.getSession().createQuery(sql.toString()).setString(0, emigId).list();
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}
}
