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- AnInternalDirectoryEntity, which an implementation of this DAO is handlingU- AnInternalEntityAttribute, 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
-
Field Summary
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, statelessSessionBatchProcessor, timeSourceFields inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
sessionFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddAttribute(T entity, String attributeName, String attributeValue) protected <V> List<V> executeBatchedQueriesIfNecessary(EntityQuery<V> entityQuery, List<HQLQuery> hqlQueries) abstract TfindByName(long directoryId, String entityName) org.apache.commons.lang3.builder.DiffResultremoveAttribute(T entity, String attributeName) org.apache.commons.lang3.builder.DiffResultremoveAttribute(T entity, String attributeName, String attributeValue) protected org.apache.commons.lang3.builder.DiffResultStores entity attributes.protected voidupdateTimestamps(InternalEntity entity, boolean updateCreatedDate) Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
createDeleteQuery, createDeleteQuery, createQuery, createQuery, executeHQLQuery, findAllInternal, findByProperties, findByPropertiesOptional, findByProperty, findByProperty, findByPropertyOptional, findByPropertyOrThrow, getCountByProperties, getPersistentClass, load, load, loadOptional, loadReference, loadReference, remove, removeByIdIfPresent, save, saveOrUpdate, session, setBatchFinder, setBatchProcessor, setClock, setStatelessSessionBatchProcessor, toPredicates, updateMethods inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
setSessionFactory, withStatelessSession
-
Constructor Details
-
InternalDirectoryEntityHibernateDao
public InternalDirectoryEntityHibernateDao()
-
-
Method Details
-
addAttribute
-
removeAttribute
-
removeAttribute
public org.apache.commons.lang3.builder.DiffResult removeAttribute(T entity, String attributeName, String attributeValue) - Parameters:
entity- The entity to remove attributes fromattributeName- The name of the attribute to removeattributeValue- The value of the attribute to remove- Returns:
- A
DiffResultobject that encapsulates the identified differences between the original and updated attributes.
-
updateTimestamps
-
findByName
- 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- TheInternalDirectoryEntitywhich will have its attributes updatedattributesToSet- A map of attributes to attribute values which will be updated/added to entityWithAttributes- Returns:
- A
DiffResultobject that encapsulates the identified differences between the original and updated attributes.
-
executeBatchedQueriesIfNecessary
protected <V> List<V> executeBatchedQueriesIfNecessary(EntityQuery<V> entityQuery, List<HQLQuery> hqlQueries)
-