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 ) ); }
@SuppressWarnings("SimplifiableIfStatement") private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { return ( (QueryableCollection) joinable ).isManyToMany(); } return false; }
@Override public void startingEntity(EntityDefinition entityDefinition) { // see if the EntityDefinition is a root... final boolean isRoot = fetchSourceStack.isEmpty(); if ( ! isRoot ) { // if not, this call should represent a fetch which should have been handled in #startingAttribute return; } // if we get here, it is a root log.tracef( "%s Starting root entity : %s", StringHelper.repeat( ">>", fetchSourceStack.size() ), entityDefinition.getEntityPersister().getEntityName() ); if ( !supportsRootEntityReturns() ) { throw new HibernateException( "This strategy does not support root entity returns" ); } final EntityReturnImpl entityReturn = new EntityReturnImpl( entityDefinition, querySpaces ); addRootReturn( entityReturn ); pushToStack( entityReturn ); // also add an AssociationKey for the root so we can later on recognize circular references back to the root. final Joinable entityPersister = (Joinable) entityDefinition.getEntityPersister(); associationKeyRegistered( new AssociationKey( entityPersister.getTableName(), entityPersister.getKeyColumnNames() ) ); }
private void addSubclassJoins( JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin, boolean includeSubclassJoins, Set<String> treatAsDeclarations) { final boolean include = includeSubclassJoins && isIncluded( alias ); joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include, treatAsDeclarations ), joinable.whereJoinFragment( alias, innerJoin, include, treatAsDeclarations ) ); }
? null : collectionSuffixes[collectionAliasCount]; final String selectFragment = joinable.selectFragment( next == null ? null : next.getJoinable(), next == null ? null : next.getRHSAlias(), buf.append( ", " ).append( selectFragment ); if ( joinable.consumesEntityAlias() ) { entityAliasCount++; if ( joinable.consumesCollectionAlias() && join.getJoinType() == JoinType.LEFT_OUTER_JOIN && !join.hasRestriction() ) {
Joinable last; if ( rootJoinable != null ) { joinFragment.addCrossJoin( rootJoinable.getTableName(), rootAlias ); final String filterCondition = rootJoinable.filterFragment( rootAlias, enabledFilters, treatAsDeclarations ); joinFragment.addFromFragmentString( first.joinable.getTableName() ); joinFragment.addFromFragmentString( " " ); joinFragment.addFromFragmentString( first.getAlias() ); join.getJoinable().getTableName(), join.getAlias(), join.getLHSColumns(), join.getJoinable().getTableName(), join.getAlias(), join.getLHSColumns(),
private FromElement createFromElement(EntityPersister entityPersister) { Joinable joinable = (Joinable) entityPersister; String text = joinable.getTableName(); AST ast = createFromElement( text ); FromElement element = (FromElement) ast; return element; }
final String[] lhsColumnNames; if ( joinable.isCollection() ) { final QueryableCollection collectionPersister = (QueryableCollection) joinable; lhsTableName = collectionPersister.getTableName(); return new AssociationKey( joinable.getTableName(), getRHSColumnNames( type, sessionFactory() ) );
public JoinDefinedByMetadata createCollectionJoin( QuerySpace leftHandSide, String lhsPropertyName, CollectionQuerySpace rightHandSide, boolean rightHandSideRequired, CollectionType joinedPropertyType, SessionFactoryImplementor sessionFactory) { return new JoinImpl( leftHandSide, lhsPropertyName, rightHandSide, joinedPropertyType.getAssociatedJoinable( sessionFactory ).getKeyColumnNames(), joinedPropertyType, rightHandSideRequired ); }
boolean checkForSqlAlias = joinable.consumesEntityAlias(); if ( !checkForSqlAlias && joinable.isCollection() ) { sqlAlias = subcriteria == null ? null : translator.getSQLAlias( subcriteria ); if ( joinable.consumesEntityAlias() && !translator.hasProjection() ) { includeInResultRowList.add( subcriteria != null && subcriteria.getAlias() != null ); if ( sqlAlias != null ) {
/** * Count the number of instances of Joinable which are actually * also instances of Loadable, or are one-to-many associations */ protected static int countEntityPersisters(List associations) throws MappingException { int result = 0; for ( Object association : associations ) { final OuterJoinableAssociation oj = (OuterJoinableAssociation) association; if ( oj.getJoinable().consumesEntityAlias() ) { result++; } } return result; }
@Override public String getOnCondition( String alias, SessionFactoryImplementor factory, Map enabledFilters, Set<String> treatAsDeclarations) { return getAssociatedJoinable( factory ).filterFragment( alias, enabledFilters, treatAsDeclarations ); }
protected String generateTableAlias(final int n, final PropertyPath path, final Joinable joinable) { return StringHelper.generateAlias( joinable.getName(), n ); }
@Override public String filterFragment(String alias) throws MappingException { String result = super.filterFragment( alias ); if ( getElementPersister() instanceof Joinable ) { result += ( (Joinable) getElementPersister() ).oneToManyFilterFragment( alias ); } return result; }
@Override public String fromJoinFragment( String alias, boolean innerJoin, boolean includeSubclasses, Set<String> treatAsDeclarations) { return ( (Joinable) getElementPersister() ).fromJoinFragment( alias, innerJoin, includeSubclasses, treatAsDeclarations ); }
joinable.selectFragment( null, null,
? null : collectionSuffixes[collectionAliasCount]; final String selectFragment = joinable.selectFragment( next == null ? null : next.getJoinable(), next == null ? null : next.getRHSAlias(), buf.append(", ").append(selectFragment); if ( joinable.consumesEntityAlias() ) entityAliasCount++; if ( joinable.consumesCollectionAlias() && join.getJoinType()==JoinType.LEFT_OUTER_JOIN ) collectionAliasCount++;
public JoinFragment toJoinFragment(Map enabledFilters, boolean includeExtraJoins) throws MappingException { QueryJoinFragment joinFragment = new QueryJoinFragment( factory.getDialect(), useThetaStyle ); if ( rootJoinable != null ) { joinFragment.addCrossJoin( rootJoinable.getTableName(), rootAlias ); String filterCondition = rootJoinable.filterFragment( rootAlias, enabledFilters ); join.getJoinable().getTableName(), join.getAlias(), join.getLHSColumns(),
@Override public String getTableName() { return ( (Joinable) getElementPersister() ).getTableName(); }
/** * Get the columns of the associated table which are to be used in the join * * @param type The type * @param factory The SessionFactory * * @return The columns for the right-hand-side of the join */ public static String[] getRHSColumnNames(AssociationType type, SessionFactoryImplementor factory) { final String uniqueKeyPropertyName = type.getRHSUniqueKeyPropertyName(); final Joinable joinable = type.getAssociatedJoinable( factory ); if ( uniqueKeyPropertyName == null ) { return joinable.getKeyColumnNames(); } else { return ( (OuterJoinLoadable) joinable ).getPropertyColumnNames( uniqueKeyPropertyName ); } }