class HibernateAttributeSetDAO extends HibernatePersistentObjectDAO<AttributeSet> implements AttributeSetDAO {

	@Override
	public Map<String, Attribute> findAttributes(long tenantId, Long setId) {
		List<AttributeSet> sets = new ArrayList<AttributeSet>();
		if (setId != null)
			sets.add(findById(setId));
		else
			sets.addAll(findAll(tenantId));

		Map<String, Attribute> attributes = new TreeMap<String, Attribute>();
		for (AttributeSet set : sets) {
			initialize(set);
			Map<String, Attribute> localAttributes = set.getAttributes();
			for (String name : localAttributes.keySet())
				if (!attributes.containsKey(name))
					attributes.put(name, localAttributes.get(name));
		}

		return attributes;
	}

	public  HibernateAttributeSetDAO();

}