use of org.hibernate.mapping.IdentifierBag in project hibernate-orm by hibernate.
the class ValueVisitorTest method testProperCallbacks.
@Test
public void testProperCallbacks() {
final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();
final Table tbl = new Table();
final RootClass rootClass = new RootClass(metadataBuildingContext);
ValueVisitor vv = new ValueVisitorValidator();
new Any(metadata, tbl).accept(vv);
new Array(metadata, rootClass).accept(vv);
new Bag(metadata, rootClass).accept(vv);
new Component(metadata, rootClass).accept(vv);
new DependantValue(metadata, tbl, null).accept(vv);
new IdentifierBag(metadata, rootClass).accept(vv);
new List(metadata, rootClass).accept(vv);
new ManyToOne(metadata, tbl).accept(vv);
new Map(metadata, rootClass).accept(vv);
new OneToMany(metadata, rootClass).accept(vv);
new OneToOne(metadata, tbl, rootClass).accept(vv);
new PrimitiveArray(metadata, rootClass).accept(vv);
new Set(metadata, rootClass).accept(vv);
new SimpleValue(metadata).accept(vv);
}
use of org.hibernate.mapping.IdentifierBag in project hibernate-orm by hibernate.
the class ModelBinder method createPluralAttribute.
private Property createPluralAttribute(MappingDocument sourceDocument, PluralAttributeSource attributeSource, PersistentClass entityDescriptor) {
final Collection collectionBinding;
if (attributeSource instanceof PluralAttributeSourceListImpl) {
collectionBinding = new org.hibernate.mapping.List(sourceDocument.getMetadataCollector(), entityDescriptor);
bindCollectionMetadata(sourceDocument, attributeSource, collectionBinding);
registerSecondPass(new PluralAttributeListSecondPass(sourceDocument, (IndexedPluralAttributeSource) attributeSource, (org.hibernate.mapping.List) collectionBinding), sourceDocument);
} else if (attributeSource instanceof PluralAttributeSourceSetImpl) {
collectionBinding = new Set(sourceDocument.getMetadataCollector(), entityDescriptor);
bindCollectionMetadata(sourceDocument, attributeSource, collectionBinding);
registerSecondPass(new PluralAttributeSetSecondPass(sourceDocument, attributeSource, collectionBinding), sourceDocument);
} else if (attributeSource instanceof PluralAttributeSourceMapImpl) {
collectionBinding = new org.hibernate.mapping.Map(sourceDocument.getMetadataCollector(), entityDescriptor);
bindCollectionMetadata(sourceDocument, attributeSource, collectionBinding);
registerSecondPass(new PluralAttributeMapSecondPass(sourceDocument, (IndexedPluralAttributeSource) attributeSource, (org.hibernate.mapping.Map) collectionBinding), sourceDocument);
} else if (attributeSource instanceof PluralAttributeSourceBagImpl) {
collectionBinding = new Bag(sourceDocument.getMetadataCollector(), entityDescriptor);
bindCollectionMetadata(sourceDocument, attributeSource, collectionBinding);
registerSecondPass(new PluralAttributeBagSecondPass(sourceDocument, attributeSource, collectionBinding), sourceDocument);
} else if (attributeSource instanceof PluralAttributeSourceIdBagImpl) {
collectionBinding = new IdentifierBag(sourceDocument.getMetadataCollector(), entityDescriptor);
bindCollectionMetadata(sourceDocument, attributeSource, collectionBinding);
registerSecondPass(new PluralAttributeIdBagSecondPass(sourceDocument, attributeSource, collectionBinding), sourceDocument);
} else if (attributeSource instanceof PluralAttributeSourceArrayImpl) {
final PluralAttributeSourceArray arraySource = (PluralAttributeSourceArray) attributeSource;
collectionBinding = new Array(sourceDocument.getMetadataCollector(), entityDescriptor);
bindCollectionMetadata(sourceDocument, attributeSource, collectionBinding);
((Array) collectionBinding).setElementClassName(sourceDocument.qualifyClassName(arraySource.getElementClass()));
registerSecondPass(new PluralAttributeArraySecondPass(sourceDocument, arraySource, (Array) collectionBinding), sourceDocument);
} else if (attributeSource instanceof PluralAttributeSourcePrimitiveArrayImpl) {
collectionBinding = new PrimitiveArray(sourceDocument.getMetadataCollector(), entityDescriptor);
bindCollectionMetadata(sourceDocument, attributeSource, collectionBinding);
registerSecondPass(new PluralAttributePrimitiveArraySecondPass(sourceDocument, (IndexedPluralAttributeSource) attributeSource, (PrimitiveArray) collectionBinding), sourceDocument);
} else {
throw new AssertionFailure("Unexpected PluralAttributeSource type : " + attributeSource.getClass().getName());
}
sourceDocument.getMetadataCollector().addCollectionBinding(collectionBinding);
final Property attribute = new Property();
attribute.setValue(collectionBinding);
bindProperty(sourceDocument, attributeSource, attribute);
return attribute;
}
Aggregations