Class InternalDirectoryEntityHibernateDao<T extends InternalDirectoryEntity<U>,U extends InternalEntityAttribute>

java.lang.Object
com.atlassian.crowd.util.persistence.hibernate.StatelessDao
com.atlassian.crowd.util.persistence.hibernate.HibernateDao<T>
com.atlassian.crowd.util.persistence.hibernate.InternalDirectoryEntityHibernateDao<T,U>
Type Parameters:
T - An InternalDirectoryEntity, which an implementation of this DAO is handling
U - An InternalEntityAttribute, which the T type uses for its attributes
Direct Known Subclasses:
GroupDAOHibernate, UserDAOHibernate

public abstract class InternalDirectoryEntityHibernateDao<T extends InternalDirectoryEntity<U>,U extends InternalEntityAttribute> extends HibernateDao<T>
Superclass for DAOs that deal with InternalDirectoryEntity, it has common logic for operating on attributes
Since:
2.10.0
  • Constructor Details

    • InternalDirectoryEntityHibernateDao

      public InternalDirectoryEntityHibernateDao()
  • Method Details

    • addAttribute

      public abstract void addAttribute(T entity, String attributeName, String attributeValue)
    • removeAttribute

      public org.apache.commons.lang3.builder.DiffResult removeAttribute(T entity, String attributeName)
    • removeAttribute

      public org.apache.commons.lang3.builder.DiffResult removeAttribute(T entity, String attributeName, String attributeValue)
      Parameters:
      entity - The entity to remove attributes from
      attributeName - The name of the attribute to remove
      attributeValue - The value of the attribute to remove
      Returns:
      A DiffResult object that encapsulates the identified differences between the original and updated attributes.
    • updateTimestamps

      protected void updateTimestamps(InternalEntity entity, boolean updateCreatedDate)
    • findByName

      public abstract T findByName(long directoryId, String entityName) throws ObjectNotFoundException
      Throws:
      ObjectNotFoundException
    • storeAttributes

      protected org.apache.commons.lang3.builder.DiffResult storeAttributes(T entityWithAttributes, Map<String,Set<String>> attributesToSet)
      Stores entity attributes. This method will:
      • Iterate through the attributes that were provided
      • If an attribute exists:
        • Existing attribute entities will have their values changed to match the new ones
        • If more attribute values were provided than the entity with attributes has then new attributes will be inserted
        • If less values were provided than the entity with attributes has then the remaining values will be removed
      • If an attribute does not exist it will be added

      It is not possible to completely remove an attribute using this method. If removal is needed then removeAttribute(InternalDirectoryEntity, String) should be used instead.

      Parameters:
      entityWithAttributes - The InternalDirectoryEntity which will have its attributes updated
      attributesToSet - A map of attributes to attribute values which will be updated/added to entityWithAttributes
      Returns:
      A DiffResult object that encapsulates the identified differences between the original and updated attributes.
    • executeBatchedQueriesIfNecessary

      protected <V> List<V> executeBatchedQueriesIfNecessary(EntityQuery<V> entityQuery, List<HQLQuery> hqlQueries)