private AttributeBinding resolveTerminal(
      DomainReferenceBinding lhs,
      String terminalName,
      AttributeReference attribute,
      EntityReference subclassIndicator) {
    AttributeBinding attributeBinding =
        context()
            .getParsingContext()
            .findOrCreateAttributeBinding(
                lhs, resolveAttributeDescriptor(lhs.getFromElement(), terminalName));

    if (attributeBinding.getFromElement() == null) {
      // create the join and inject it into the binding
      attributeBinding.injectAttributeJoin(
          context()
              .getFromElementBuilder()
              .buildAttributeJoin(
                  attributeBinding,
                  alias,
                  subclassIndicator,
                  lhs.getFromElement().asLoggableText() + '.' + attribute.getAttributeName(),
                  getIntermediateJoinType(),
                  areIntermediateJoinsFetched() ? lhs.getFromElement().getUniqueIdentifier() : null,
                  canReuseImplicitJoins()));
    }

    return attributeBinding;
  }
 @Override
 protected AttributeBinding resolveTerminalAttributeBinding(
     DomainReferenceBinding lhs, String terminalName) {
   final AttributeReference attribute =
       resolveAttributeDescriptor(lhs.getFromElement(), terminalName);
   return resolveTerminal(lhs, terminalName, attribute, null);
 }
 @Override
 protected DomainReferenceBinding resolveFromElementAliasAsTerminal(
     DomainReferenceBinding aliasedBinding) {
   // this can never be valid...
   throw new SemanticException(
       "Cannot join to aliased FromElement ["
           + aliasedBinding.getFromElement().getIdentificationVariable()
           + "]");
 }
 @Override
 protected DomainReferenceBinding resolveTreatedTerminal(
     ResolutionContext context,
     DomainReferenceBinding lhs,
     String terminalName,
     EntityReference subclassIndicator) {
   final AttributeReference attribute =
       resolveAttributeDescriptor(lhs.getFromElement(), terminalName);
   return resolveTerminal(lhs, terminalName, attribute, subclassIndicator);
 }