Class AbstractCollectionMapper<T>
- java.lang.Object
-
- org.hibernate.envers.internal.entities.mapper.AbstractMapper
-
- org.hibernate.envers.internal.entities.mapper.AbstractPropertyMapper
-
- org.hibernate.envers.internal.entities.mapper.relation.AbstractCollectionMapper<T>
-
- All Implemented Interfaces:
DynamicComponentMapperSupport,ModifiedFlagMapperSupport,PropertyMapper
- Direct Known Subclasses:
BasicCollectionMapper,ListCollectionMapper,MapCollectionMapper
public abstract class AbstractCollectionMapper<T> extends AbstractPropertyMapper
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<? extends T>collectionClassprotected CommonCollectionMapperDatacommonCollectionMapperDataprotected Configurationconfigurationprotected booleanordinalInIdprotected booleanrevisionTypeInId
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCollectionMapper(Configuration configuration, CommonCollectionMapperData commonCollectionMapperData, Class<? extends T> collectionClass, Class<? extends T> proxyClass, boolean ordinalInId, boolean revisionTypeInId)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddCollectionChanges(SessionImplementor session, List<PersistentCollectionChangeData> collectionChanges, Set<Object> changed, RevisionType revisionType, Object id)protected abstract Set<Object>buildCollectionChangeSet(Object eventCollection, Collection collection)protected Map<String,Object>createIdMap(int ordinal)Creates map for storing identifier data.protected abstract Initializor<T>getInitializor(EnversService enversService, AuditReaderImplementor versionsReader, Object primaryKey, Number revision, boolean removed)protected abstract CollectiongetNewCollectionContent(PersistentCollection newCollection)protected abstract CollectiongetOldCollectionContent(Serializable oldCollection)booleanhasPropertiesWithModifiedFlag()Returns whether the associatedPropertyMapperhas any properties that use thewitModifiedFlagfeature.protected booleanisSame(CollectionPersister collectionPersister, Object oldObject, Object newObject)Checks whether the old collection element and new collection element are the same.List<PersistentCollectionChangeData>mapCollectionChanges(SessionImplementor session, String referencingPropertyName, PersistentCollection newColl, Serializable oldColl, Object id)Maps collection changes.protected abstract List<PersistentCollectionChangeData>mapCollectionChanges(SessionImplementor session, PersistentCollection newColl, Serializable oldColl, Object id)Map collection changes using hash identity.voidmapModifiedFlagsToMapForCollectionChange(String collectionPropertyName, Map<String,Object> data)voidmapModifiedFlagsToMapFromEntity(SessionImplementor session, Map<String,Object> data, Object newObj, Object oldObj)voidmapToEntityFromMap(EnversService enversService, Object obj, Map data, Object primaryKey, AuditReaderImplementor versionsReader, Number revision)Maps properties from the given map to the given object.ObjectmapToEntityFromMap(EnversService enversService, Map data, Object primaryKey, AuditReaderImplementor versionsReader, Number revision)booleanmapToMapFromEntity(SessionImplementor session, Map<String,Object> data, Object newObj, Object oldObj)Maps properties to the given map, basing on differences between properties of new and old objects.protected abstract voidmapToMapFromObject(SessionImplementor session, Map<String,Object> idData, Map<String,Object> data, Object changed)Maps the changed collection element to the given map.protected CollectionPersisterresolveCollectionPersister(SessionImplementor session, PersistentCollection collection)-
Methods inherited from class org.hibernate.envers.internal.entities.mapper.AbstractPropertyMapper
isDynamicComponentMap, markAsDynamicComponentMap
-
Methods inherited from class org.hibernate.envers.internal.entities.mapper.AbstractMapper
doPrivileged, getAndSetValue, getValueFromObject, getValueFromObject, newObjectInstance, setValueOnObject
-
-
-
-
Field Detail
-
configuration
protected final Configuration configuration
-
commonCollectionMapperData
protected final CommonCollectionMapperData commonCollectionMapperData
-
ordinalInId
protected final boolean ordinalInId
-
revisionTypeInId
protected final boolean revisionTypeInId
-
-
Constructor Detail
-
AbstractCollectionMapper
protected AbstractCollectionMapper(Configuration configuration, CommonCollectionMapperData commonCollectionMapperData, Class<? extends T> collectionClass, Class<? extends T> proxyClass, boolean ordinalInId, boolean revisionTypeInId)
-
-
Method Detail
-
getNewCollectionContent
protected abstract Collection getNewCollectionContent(PersistentCollection newCollection)
-
getOldCollectionContent
protected abstract Collection getOldCollectionContent(Serializable oldCollection)
-
buildCollectionChangeSet
protected abstract Set<Object> buildCollectionChangeSet(Object eventCollection, Collection collection)
-
mapToMapFromObject
protected abstract void mapToMapFromObject(SessionImplementor session, Map<String,Object> idData, Map<String,Object> data, Object changed)
Maps the changed collection element to the given map.- Parameters:
idData- Map to which composite-id data should be added.data- Where to map the data.changed- The changed collection element to map.
-
createIdMap
protected Map<String,Object> createIdMap(int ordinal)
Creates map for storing identifier data. Ordinal parameter guarantees uniqueness of primary key. Composite primary key cannot contain embeddable properties since they might be nullable.- Parameters:
ordinal- Iteration ordinal.- Returns:
- Map for holding identifier data.
-
addCollectionChanges
protected void addCollectionChanges(SessionImplementor session, List<PersistentCollectionChangeData> collectionChanges, Set<Object> changed, RevisionType revisionType, Object id)
-
mapCollectionChanges
public List<PersistentCollectionChangeData> mapCollectionChanges(SessionImplementor session, String referencingPropertyName, PersistentCollection newColl, Serializable oldColl, Object id)
Description copied from interface:PropertyMapperMaps collection changes.- Parameters:
session- The current session.referencingPropertyName- Name of the field, which holds the collection in the entity.newColl- New collection, after updates.oldColl- Old collection, before updates.id- Id of the object owning the collection.- Returns:
- List of changes that need to be performed on the persistent store.
-
mapToMapFromEntity
public boolean mapToMapFromEntity(SessionImplementor session, Map<String,Object> data, Object newObj, Object oldObj)
Description copied from interface:PropertyMapperMaps properties to the given map, basing on differences between properties of new and old objects.- Parameters:
session- The current session.data- Data to map to.newObj- New state of the entity.oldObj- Old state of the entity.- Returns:
- True if there are any differences between the states represented by newObj and oldObj.
-
mapModifiedFlagsToMapFromEntity
public void mapModifiedFlagsToMapFromEntity(SessionImplementor session, Map<String,Object> data, Object newObj, Object oldObj)
-
mapModifiedFlagsToMapForCollectionChange
public void mapModifiedFlagsToMapForCollectionChange(String collectionPropertyName, Map<String,Object> data)
-
getInitializor
protected abstract Initializor<T> getInitializor(EnversService enversService, AuditReaderImplementor versionsReader, Object primaryKey, Number revision, boolean removed)
-
resolveCollectionPersister
protected CollectionPersister resolveCollectionPersister(SessionImplementor session, PersistentCollection collection)
-
isSame
protected boolean isSame(CollectionPersister collectionPersister, Object oldObject, Object newObject)
Checks whether the old collection element and new collection element are the same. By default, this delegates to the collection persister'sCollectionPersister.getElementType().- Parameters:
collectionPersister- The collection persister.oldObject- The collection element from the old persistent collection.newObject- The collection element from the new persistent collection.- Returns:
- true if the two objects are the same, false otherwise.
-
mapToEntityFromMap
public void mapToEntityFromMap(EnversService enversService, Object obj, Map data, Object primaryKey, AuditReaderImplementor versionsReader, Number revision)
Description copied from interface:PropertyMapperMaps properties from the given map to the given object.- Parameters:
enversService- The EnversService.obj- Object to map to.data- Data to map from.primaryKey- Primary key of the object to which we map (for relations)versionsReader- VersionsReader for reading relationsrevision- Revision at which the object is read, for reading relations
-
mapToEntityFromMap
public Object mapToEntityFromMap(EnversService enversService, Map data, Object primaryKey, AuditReaderImplementor versionsReader, Number revision)
-
mapCollectionChanges
protected abstract List<PersistentCollectionChangeData> mapCollectionChanges(SessionImplementor session, PersistentCollection newColl, Serializable oldColl, Object id)
Map collection changes using hash identity.- Parameters:
session- The session.newColl- The new persistent collection.oldColl- The old collection.id- The owning entity identifier.- Returns:
- the persistent collection changes.
-
hasPropertiesWithModifiedFlag
public boolean hasPropertiesWithModifiedFlag()
Description copied from interface:ModifiedFlagMapperSupportReturns whether the associatedPropertyMapperhas any properties that use thewitModifiedFlagfeature.- Returns:
trueif a property useswithModifiedFlag, otherwisefalse.
-
-