class HibernateMenuDAO extends HibernatePersistentObjectDAO<Menu> implements MenuDAO {

	@Override
	public boolean applyRightToTree(long id) {
		boolean result = true;
		try {
			Menu parent = findById(id);
			Long securityRef = id;
			if (parent.getSecurityRef() != null)
				securityRef = parent.getSecurityRef();

			// Iterate over all children setting the security reference
			List<Menu> children = findChildren(id, null);
			for (Menu menu : children) {
				if (!securityRef.equals(menu.getSecurityRef())) {
					menu.setSecurityRef(securityRef);
					menu.getMenuGroups().clear();
					store(menu);
				}
				applyRightToTree(menu.getId());
			}
		} catch (Throwable e) {
			if (log.isErrorEnabled())
				log.error(e.getMessage(), e);
			result = false;
		}

		return result;
	}

	protected  HibernateMenuDAO();

}