use of org.hibernate.type.BagType 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);
}
}
use of org.hibernate.type.BagType in project hibernate-orm by hibernate.
the class CollectionMetadataGenerator method addCollection.
void addCollection() {
final Type type = propertyValue.getType();
final Value value = propertyValue.getElement();
final boolean oneToManyAttachedType = type instanceof BagType || type instanceof SetType || type instanceof MapType || type instanceof ListType;
final boolean inverseOneToMany = (value instanceof OneToMany) && (propertyValue.isInverse());
final boolean owningManyToOneWithJoinTableBidirectional = (value instanceof ManyToOne) && (propertyAuditingData.getRelationMappedBy() != null);
final boolean fakeOneToManyBidirectional = (value instanceof OneToMany) && (propertyAuditingData.getAuditMappedBy() != null);
if (oneToManyAttachedType && (inverseOneToMany || fakeOneToManyBidirectional || owningManyToOneWithJoinTableBidirectional)) {
// A one-to-many relation mapped using @ManyToOne and @OneToMany(mappedBy="...")
addOneToManyAttached(fakeOneToManyBidirectional);
} else {
// All other kinds of relations require a middle (join) table.
addWithMiddleTable();
}
}
use of org.hibernate.type.BagType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsArrayType.
@Test
public void testIsArrayType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
Assert.assertFalse(typeFacade.isArrayType());
BagType bagType = new BagType(null, null, false);
typeFacade = FACADE_FACTORY.createType(bagType);
Assert.assertFalse(typeFacade.isArrayType());
ArrayType arrayType = new ArrayType(null, null, String.class, false);
typeFacade = FACADE_FACTORY.createType(arrayType);
Assert.assertTrue(typeFacade.isArrayType());
}
use of org.hibernate.type.BagType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsArrayType.
@Test
public void testIsArrayType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
Assert.assertFalse(typeFacade.isArrayType());
BagType bagType = new BagType(null, null, null, false);
typeFacade = FACADE_FACTORY.createType(bagType);
Assert.assertFalse(typeFacade.isArrayType());
ArrayType arrayType = new ArrayType(null, null, null, String.class, false);
typeFacade = FACADE_FACTORY.createType(arrayType);
Assert.assertTrue(typeFacade.isArrayType());
}
use of org.hibernate.type.BagType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsArrayType.
@Test
public void testIsArrayType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
Assert.assertFalse(typeFacade.isArrayType());
BagType bagType = new BagType(null, null, null);
typeFacade = FACADE_FACTORY.createType(bagType);
Assert.assertFalse(typeFacade.isArrayType());
ArrayType arrayType = new ArrayType(null, null, null, String.class);
typeFacade = FACADE_FACTORY.createType(arrayType);
Assert.assertTrue(typeFacade.isArrayType());
}
Aggregations