use of org.hibernate.type.AnyType in project hibernate-orm by hibernate.
the class AbstractPropertyMapping method addPropertyPath.
protected void addPropertyPath(String path, Type type, String[] columns, String[] columnReaders, String[] columnReaderTemplates, String[] formulaTemplates, Mapping factory) {
Type existingType = typesByPropertyPath.get(path);
if (existingType != null || duplicateIncompatiblePaths.contains(path)) {
// If types match or the new type is not an association type, there is nothing for us to do
if (type == existingType || existingType == null || !(type instanceof AssociationType)) {
logDuplicateRegistration(path, existingType, type);
} else if (!(existingType instanceof AssociationType)) {
// Workaround for org.hibernate.cfg.annotations.PropertyBinder.bind() adding a component for *ToOne ids
logDuplicateRegistration(path, existingType, type);
} else {
if (type instanceof AnyType && existingType instanceof AnyType) {
// TODO: not sure how to handle any types. For now we just return and let the first type dictate what type the property has...
} else {
Type commonType = null;
MetadataImplementor metadata = (MetadataImplementor) factory;
if (type instanceof CollectionType && existingType instanceof CollectionType) {
Collection thisCollection = metadata.getCollectionBinding(((CollectionType) existingType).getRole());
Collection otherCollection = metadata.getCollectionBinding(((CollectionType) type).getRole());
if (thisCollection.isSame(otherCollection)) {
logDuplicateRegistration(path, existingType, type);
return;
} else {
logIncompatibleRegistration(path, existingType, type);
}
} else if (type instanceof EntityType && existingType instanceof EntityType) {
EntityType entityType1 = (EntityType) existingType;
EntityType entityType2 = (EntityType) type;
if (entityType1.getAssociatedEntityName().equals(entityType2.getAssociatedEntityName())) {
logDuplicateRegistration(path, existingType, type);
return;
} else {
commonType = getCommonType(metadata, entityType1, entityType2);
}
} else {
logIncompatibleRegistration(path, existingType, type);
}
if (commonType == null) {
duplicateIncompatiblePaths.add(path);
typesByPropertyPath.remove(path);
// Set everything to empty to signal action has to be taken!
// org.hibernate.hql.internal.ast.tree.DotNode.dereferenceEntityJoin() is reacting to this
String[] empty = new String[0];
columnsByPropertyPath.put(path, empty);
columnReadersByPropertyPath.put(path, empty);
columnReaderTemplatesByPropertyPath.put(path, empty);
if (formulaTemplates != null) {
formulaTemplatesByPropertyPath.put(path, empty);
}
} else {
typesByPropertyPath.put(path, commonType);
}
}
}
} else {
typesByPropertyPath.put(path, type);
columnsByPropertyPath.put(path, columns);
columnReadersByPropertyPath.put(path, columnReaders);
columnReaderTemplatesByPropertyPath.put(path, columnReaderTemplates);
if (formulaTemplates != null) {
formulaTemplatesByPropertyPath.put(path, formulaTemplates);
}
}
}
use of org.hibernate.type.AnyType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsAnyType.
@Test
public void testIsAnyType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertFalse(typeFacade.isAnyType());
AnyType anyType = new AnyType(null, null, null);
typeFacade = FACADE_FACTORY.createType(anyType);
assertTrue(typeFacade.isAnyType());
}
use of org.hibernate.type.AnyType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsAnyType.
@Test
public void testIsAnyType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertFalse(typeFacade.isAnyType());
AnyType anyType = new AnyType(null, null, null, true);
typeFacade = FACADE_FACTORY.createType(anyType);
assertTrue(typeFacade.isAnyType());
}
use of org.hibernate.type.AnyType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsAnyType.
@Test
public void testIsAnyType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertFalse(typeFacade.isAnyType());
AnyType anyType = new AnyType(null, null, null, true);
typeFacade = FACADE_FACTORY.createType(anyType);
assertTrue(typeFacade.isAnyType());
}
use of org.hibernate.type.AnyType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsAnyType.
@Test
public void testIsAnyType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertFalse(typeFacade.isAnyType());
AnyType anyType = new AnyType(null, null, null, true);
typeFacade = FACADE_FACTORY.createType(anyType);
assertTrue(typeFacade.isAnyType());
}
Aggregations