class HibernateMessageTemplateDAO extends HibernatePersistentObjectDAO<MessageTemplate> implements MessageTemplateDAO {

	@Override
	public List<MessageTemplate> findByTypeAndLanguage(String type, String language, long tenantId) {
		StringBuffer query = new StringBuffer("_entity.language='" + language + "' ");
		query.append(" and _entity.tenantId=" + tenantId);
		if (StringUtils.isNotEmpty(type))
			query.append(" and _entity.type='" + type + "' ");

		try {
			return findByWhere(query.toString(), "order by _entity.name", null);
		} catch (PersistenceException e) {
			log.error(e.getMessage(), e);
			return new ArrayList<MessageTemplate>();
		}
	}

	public  HibernateMessageTemplateDAO();

}