protected void indexQualifiers( final PersistentDescriptor descriptor, EntityInheritanceTree inheritanceTree) { Expression qualifier; if (inheritanceTree != null) { qualifier = inheritanceTree.qualifierForEntityAndSubclasses(); } else { qualifier = descriptor.getEntity().getDeclaredQualifier(); } if (qualifier != null) { // using map instead of a Set to collect attributes, as // ObjEntity.getAttribute may return a decorator for attribute on // each call, resulting in dupes final Map<String, ObjAttribute> attributes = new HashMap<>(); final DbEntity dbEntity = descriptor.getEntity().getDbEntity(); qualifier.traverse( new TraversalHelper() { @Override public void startNode(Expression node, Expression parentNode) { if (node.getType() == Expression.DB_PATH) { String path = node.getOperand(0).toString(); final DbAttribute attribute = dbEntity.getAttribute(path); if (attribute != null) { ObjAttribute objectAttribute = descriptor.getEntity().getAttributeForDbAttribute(attribute); if (objectAttribute == null) { objectAttribute = new ObjAttribute(attribute.getName()) { @Override public DbAttribute getDbAttribute() { return attribute; } }; // we semi-officially DO NOT support inheritance // descriptors based on related entities, so // here we // assume that DbAttribute is rooted in the root // DbEntity, and no relationship is involved. objectAttribute.setDbAttributePath(attribute.getName()); objectAttribute.setType(TypesMapping.getJavaBySqlType(attribute.getType())); } attributes.put(objectAttribute.getName(), objectAttribute); } } else if (node.getType() == Expression.OBJ_PATH) { String path = node.getOperand(0).toString(); ObjAttribute attribute = descriptor.getEntity().getAttribute(path); attributes.put(path, attribute); } } }); descriptor.setDiscriminatorColumns(attributes.values()); descriptor.setEntityQualifier(qualifier); } }