package com.palmnest.dao.repair.impl;

import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.dao.repair.RepairBillCommentDao;
import com.palmnest.model.repair.RepairBillComment;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("repairBillCommentDao")
public class RepairBillCommentDaoImpl extends GenericDaoHibernate<RepairBillComment, Long> implements RepairBillCommentDao {

	public RepairBillCommentDaoImpl() {
		super(RepairBillComment.class);
	}

	@Override
	public RepairBillComment findBy(Long billId) {
		String                  strHql = "from RepairBillComment where billId = ? order by createTime desc";
		List<RepairBillComment> list   = getSession().createQuery(strHql).setLong(0, billId).list();
		if (list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

}
