Search in sources :

Example 1 with SortedSetCollectionMapper

use of org.hibernate.envers.internal.entities.mapper.relation.SortedSetCollectionMapper in project hibernate-orm by hibernate.

the class CollectionMetadataGenerator method addMapper.

private void addMapper(CommonCollectionMapperData commonCollectionMapperData, MiddleComponentData elementComponentData, MiddleComponentData indexComponentData) {
    final Type type = propertyValue.getType();
    final boolean embeddableElementType = isEmbeddableElementType();
    final boolean lobMapElementType = isLobMapElementType();
    if (type instanceof SortedSetType) {
        currentMapper.addComposite(propertyAuditingData.getPropertyData(), new SortedSetCollectionMapper(commonCollectionMapperData, TreeSet.class, SortedSetProxy.class, elementComponentData, propertyValue.getComparator(), embeddableElementType, embeddableElementType));
    } else if (type instanceof SetType) {
        currentMapper.addComposite(propertyAuditingData.getPropertyData(), new BasicCollectionMapper<Set>(commonCollectionMapperData, HashSet.class, SetProxy.class, elementComponentData, embeddableElementType, embeddableElementType));
    } else if (type instanceof SortedMapType) {
        // Indexed collection, so <code>indexComponentData</code> is not null.
        currentMapper.addComposite(propertyAuditingData.getPropertyData(), new SortedMapCollectionMapper(commonCollectionMapperData, TreeMap.class, SortedMapProxy.class, elementComponentData, indexComponentData, propertyValue.getComparator(), embeddableElementType || lobMapElementType));
    } else if (type instanceof MapType) {
        // Indexed collection, so <code>indexComponentData</code> is not null.
        currentMapper.addComposite(propertyAuditingData.getPropertyData(), new MapCollectionMapper<Map>(commonCollectionMapperData, HashMap.class, MapProxy.class, elementComponentData, indexComponentData, embeddableElementType || lobMapElementType));
    } else if (type instanceof BagType) {
        currentMapper.addComposite(propertyAuditingData.getPropertyData(), new BasicCollectionMapper<List>(commonCollectionMapperData, ArrayList.class, ListProxy.class, elementComponentData, embeddableElementType, embeddableElementType));
    } else if (type instanceof ListType) {
        // Indexed collection, so <code>indexComponentData</code> is not null.
        currentMapper.addComposite(propertyAuditingData.getPropertyData(), new ListCollectionMapper(commonCollectionMapperData, elementComponentData, indexComponentData, embeddableElementType));
    } else {
        mainGenerator.throwUnsupportedTypeException(type, referencingEntityName, propertyName);
    }
}
Also used : SortedSetType(org.hibernate.type.SortedSetType) SortedMapCollectionMapper(org.hibernate.envers.internal.entities.mapper.relation.SortedMapCollectionMapper) MapCollectionMapper(org.hibernate.envers.internal.entities.mapper.relation.MapCollectionMapper) SortedSetCollectionMapper(org.hibernate.envers.internal.entities.mapper.relation.SortedSetCollectionMapper) SortedSetProxy(org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.SortedSetProxy) ArrayList(java.util.ArrayList) ListCollectionMapper(org.hibernate.envers.internal.entities.mapper.relation.ListCollectionMapper) SortedMapCollectionMapper(org.hibernate.envers.internal.entities.mapper.relation.SortedMapCollectionMapper) TreeMap(java.util.TreeMap) MapType(org.hibernate.type.MapType) SortedMapType(org.hibernate.type.SortedMapType) ListType(org.hibernate.type.ListType) ManyToOneType(org.hibernate.type.ManyToOneType) MaterializedNClobType(org.hibernate.type.MaterializedNClobType) SetType(org.hibernate.type.SetType) MaterializedClobType(org.hibernate.type.MaterializedClobType) MapType(org.hibernate.type.MapType) ComponentType(org.hibernate.type.ComponentType) SortedSetType(org.hibernate.type.SortedSetType) SortedMapType(org.hibernate.type.SortedMapType) BagType(org.hibernate.type.BagType) Type(org.hibernate.type.Type) SortedMapProxy(org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.SortedMapProxy) SetType(org.hibernate.type.SetType) SortedSetType(org.hibernate.type.SortedSetType) TreeSet(java.util.TreeSet) BagType(org.hibernate.type.BagType) BasicCollectionMapper(org.hibernate.envers.internal.entities.mapper.relation.BasicCollectionMapper) SortedMapType(org.hibernate.type.SortedMapType) ListProxy(org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.ListProxy) ListType(org.hibernate.type.ListType) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 BasicCollectionMapper (org.hibernate.envers.internal.entities.mapper.relation.BasicCollectionMapper)1 ListCollectionMapper (org.hibernate.envers.internal.entities.mapper.relation.ListCollectionMapper)1 MapCollectionMapper (org.hibernate.envers.internal.entities.mapper.relation.MapCollectionMapper)1 SortedMapCollectionMapper (org.hibernate.envers.internal.entities.mapper.relation.SortedMapCollectionMapper)1 SortedSetCollectionMapper (org.hibernate.envers.internal.entities.mapper.relation.SortedSetCollectionMapper)1 ListProxy (org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.ListProxy)1 SortedMapProxy (org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.SortedMapProxy)1 SortedSetProxy (org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.SortedSetProxy)1 BagType (org.hibernate.type.BagType)1 ComponentType (org.hibernate.type.ComponentType)1 ListType (org.hibernate.type.ListType)1 ManyToOneType (org.hibernate.type.ManyToOneType)1 MapType (org.hibernate.type.MapType)1 MaterializedClobType (org.hibernate.type.MaterializedClobType)1 MaterializedNClobType (org.hibernate.type.MaterializedNClobType)1 SetType (org.hibernate.type.SetType)1