class HibernateSystemMessageDAO extends HibernatePersistentObjectDAO<SystemMessage> implements SystemMessageDAO {

	@Override
	public int getUnreadCount(String recipient, int type) {
		String sql = "select count(distinct(R.ld_messageid)) from ld_recipient R, ld_systemmessage M "
				+ " where R.ld_name = '" + SqlUtil.doubleQuotes(recipient)
				+ "' and R.ld_messageid=M.ld_id and M.ld_deleted=0 and M.ld_type=" + type + " and R.ld_read=0";
		try {
			return queryForInt(sql);
		} catch (PersistenceException e) {
			log.error(e.getMessage(), e);
			return 0;
		}
	}

	public  HibernateSystemMessageDAO();

}