private FromElement createFromElement(EntityPersister entityPersister) {
   Joinable joinable = (Joinable) entityPersister;
   String text = joinable.getTableName();
   AST ast = createFromElement(text);
   FromElement element = (FromElement) ast;
   return element;
 }
  @Override
  public AssociationKey getAssociationKey() {
    final AssociationType type = getType();

    if (type.isAnyType()) {
      return new AssociationKey(
          JoinHelper.getLHSTableName(type, attributeNumber(), (OuterJoinLoadable) getSource()),
          JoinHelper.getLHSColumnNames(
              type, attributeNumber(), 0, (OuterJoinLoadable) getSource(), sessionFactory()));
    }

    final Joinable joinable = type.getAssociatedJoinable(sessionFactory());

    if (type.getForeignKeyDirection() == ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT) {
      final String lhsTableName;
      final String[] lhsColumnNames;

      if (joinable.isCollection()) {
        final QueryableCollection collectionPersister = (QueryableCollection) joinable;
        lhsTableName = collectionPersister.getTableName();
        lhsColumnNames = collectionPersister.getElementColumnNames();
      } else {
        final OuterJoinLoadable entityPersister = (OuterJoinLoadable) source();
        lhsTableName = getLHSTableName(type, attributeNumber(), entityPersister);
        lhsColumnNames =
            getLHSColumnNames(type, attributeNumber(), entityPersister, sessionFactory());
      }
      return new AssociationKey(lhsTableName, lhsColumnNames);
    } else {
      return new AssociationKey(joinable.getTableName(), getRHSColumnNames(type, sessionFactory()));
    }
  }
 public void addManyToManyJoin(JoinFragment outerjoin, QueryableCollection collection)
     throws MappingException {
   String manyToManyFilter = collection.getManyToManyFilterFragment(rhsAlias, enabledFilters);
   String condition =
       "".equals(manyToManyFilter)
           ? on
           : "".equals(on) ? manyToManyFilter : on + " and " + manyToManyFilter;
   outerjoin.addJoin(
       joinable.getTableName(), rhsAlias, lhsColumns, rhsColumns, joinType, condition);
   outerjoin.addJoins(
       joinable.fromJoinFragment(rhsAlias, false, true),
       joinable.whereJoinFragment(rhsAlias, false, true));
 }
 public void addJoins(JoinFragment outerjoin) throws MappingException {
   outerjoin.addJoin(joinable.getTableName(), rhsAlias, lhsColumns, rhsColumns, joinType, on);
   outerjoin.addJoins(
       joinable.fromJoinFragment(rhsAlias, false, true),
       joinable.whereJoinFragment(rhsAlias, false, true));
 }