final LockOptions lockOptions) throws MappingException { final int joins = countEntityPersisters( associations ); suffixes = BasicLoader.generateSuffixes( joins + 1 ); JoinFragment ojf = mergeOuterJoins( associations ); Select select = new Select( getDialect() ) .setLockOptions( lockOptions ) .setSelectClause( projection == null ? persister.selectFragment( alias, suffixes[joins] ) + selectString( associations ) : projection getDialect().appendLockHint( lockOptions, persister.fromTableFragment( alias ) ) + persister.fromJoinFragment( alias, true, true ) .setOuterJoins( ojf.toFromFragmentString(), ojf.toWhereFragmentString() + getWhereFragment() .setOrderByClause( orderBy( associations, orderBy ) ) .setGroupByClause( groupBy ); if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) { select.setComment( getComment() );
public AbstractEntityJoinWalker( OuterJoinLoadable persister, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers, String alias) { super( factory, loadQueryInfluencers ); this.persister = persister; this.alias = ( alias == null ) ? generateRootAlias( persister.getEntityName() ) : alias; }
protected final void initAll( final String whereString, final String orderByString, final LockOptions lockOptions, final AssociationInitCallback callback) throws MappingException { walkEntityTree( persister, getAlias() ); List allAssociations = new ArrayList(); allAssociations.addAll( associations ); allAssociations.add( OuterJoinableAssociation.createRoot( persister.getEntityType(), alias, getFactory() ) ); initPersisters( allAssociations, lockOptions, callback ); initStatementString( whereString, orderByString, lockOptions ); }
protected final void initProjection( final String projectionString, final String whereString, final String orderByString, final String groupByString, final LockOptions lockOptions) throws MappingException { walkEntityTree( persister, getAlias() ); persisters = new Loadable[0]; initStatementString(projectionString, whereString, orderByString, groupByString, lockOptions); }
protected final boolean isJoinFetchEnabledByProfile(OuterJoinLoadable persister, PropertyPath path, int propertyNumber) { if ( !getLoadQueryInfluencers().hasEnabledFetchProfiles() ) { // perf optimization return false; } // ugh, this stuff has to be made easier... final String fullPath = path.getFullPath(); String rootPropertyName = persister.getSubclassPropertyName( propertyNumber ); int pos = fullPath.lastIndexOf( rootPropertyName ); String relativePropertyPath = pos >= 0 ? fullPath.substring( pos ) : rootPropertyName; String fetchRole = persister.getEntityName() + "." + relativePropertyPath; for ( String profileName : getLoadQueryInfluencers().getEnabledFetchProfileNames() ) { final FetchProfile profile = getFactory().getFetchProfile( profileName ); final Fetch fetch = profile.getFetchByRole( fetchRole ); if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) { return true; } } return false; }
/** * Use the discriminator, to narrow the select to instances * of the queried subclass, also applying any filters. */ @Override protected String getWhereFragment() throws MappingException { return super.getWhereFragment() + ( (Queryable) getPersister() ).filterFragment( getAlias(), getLoadQueryInfluencers().getEnabledFilters() ); }
public String toString() { return getClass().getName() + '(' + getPersister().getEntityName() + ')'; } }
sqlAlias = super.generateTableAlias( n + translator.getSQLAliasCount(), path, joinable );
resolvedJoinType = super.getJoinType( persister, path, resolvedJoinType = super.getJoinType( associationType, metadataFetchMode,
protected final void initProjection( final String projectionString, final String whereString, final String orderByString, final String groupByString, final LockMode lockMode) throws MappingException { walkEntityTree( persister, getAlias() ); persisters = new Loadable[0]; initStatementString(projectionString, whereString, orderByString, groupByString, lockMode); }
protected final boolean isJoinFetchEnabledByProfile(OuterJoinLoadable persister, PropertyPath path, int propertyNumber) { if ( !getLoadQueryInfluencers().hasEnabledFetchProfiles() ) { // perf optimization return false; } // ugh, this stuff has to be made easier... final String fullPath = path.getFullPath(); String rootPropertyName = persister.getSubclassPropertyName( propertyNumber ); int pos = fullPath.lastIndexOf( rootPropertyName ); String relativePropertyPath = pos >= 0 ? fullPath.substring( pos ) : rootPropertyName; String fetchRole = persister.getEntityName() + "." + relativePropertyPath; Iterator profiles = getLoadQueryInfluencers().getEnabledFetchProfileNames().iterator(); while ( profiles.hasNext() ) { final String profileName = ( String ) profiles.next(); final FetchProfile profile = getFactory().getFetchProfile( profileName ); final Fetch fetch = profile.getFetchByRole( fetchRole ); if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) { return true; } } return false; }
/** * Use the discriminator, to narrow the select to instances * of the queried subclass, also applying any filters. */ protected String getWhereFragment() throws MappingException { return super.getWhereFragment() + ( (Queryable) getPersister() ).filterFragment( getAlias(), getEnabledFilters() ); }
public String toString() { return getClass().getName() + '(' + getPersister().getEntityName() + ')'; } }
protected String generateTableAlias(int n, String path, Joinable joinable) { if ( joinable.consumesEntityAlias() ) { final Criteria subcriteria = translator.getCriteria(path); String sqlAlias = subcriteria==null ? null : translator.getSQLAlias(subcriteria); if (sqlAlias!=null) { userAliasList.add( subcriteria.getAlias() ); //alias may be null return sqlAlias; //EARLY EXIT } else { userAliasList.add(null); } } return super.generateTableAlias( n + translator.getSQLAliasCount(), path, joinable ); }
return super.getJoinType( persister, path, return ( translator.isJoin( path.getFullPath() ) ? translator.getJoinType( path.getFullPath() ) : super.getJoinType( associationType, config,
final LockOptions lockOptions) throws MappingException { final int joins = countEntityPersisters( associations ); suffixes = BasicLoader.generateSuffixes( joins + 1 ); JoinFragment ojf = mergeOuterJoins( associations ); Select select = new Select( getDialect() ) .setLockOptions( lockOptions ) .setSelectClause( projection == null ? persister.selectFragment( alias, suffixes[joins] ) + selectString( associations ) : projection getDialect().appendLockHint( lockOptions.getLockMode(), persister.fromTableFragment( alias ) ) + persister.fromJoinFragment( alias, true, true ) .setOuterJoins( ojf.toFromFragmentString(), ojf.toWhereFragmentString() + getWhereFragment() .setOrderByClause( orderBy( associations, orderBy ) ) .setGroupByClause( groupBy ); if ( getFactory().getSettings().isCommentsEnabled() ) { select.setComment( getComment() );
protected final void initAll( final String whereString, final String orderByString, final LockOptions lockOptions, final AssociationInitCallback callback) throws MappingException { walkEntityTree( persister, getAlias() ); List allAssociations = new ArrayList(); allAssociations.addAll( associations ); allAssociations.add( OuterJoinableAssociation.createRoot( persister.getEntityType(), alias, getFactory() ) ); initPersisters( allAssociations, lockOptions, callback ); initStatementString( whereString, orderByString, lockOptions ); }
protected final void initProjection( final String projectionString, final String whereString, final String orderByString, final String groupByString, final LockOptions lockOptions) throws MappingException { walkEntityTree( persister, getAlias() ); persisters = new Loadable[0]; initStatementString(projectionString, whereString, orderByString, groupByString, lockOptions); }
protected final boolean isJoinFetchEnabledByProfile(OuterJoinLoadable persister, PropertyPath path, int propertyNumber) { if ( !getLoadQueryInfluencers().hasEnabledFetchProfiles() ) { // perf optimization return false; } // ugh, this stuff has to be made easier... final String fullPath = path.getFullPath(); String rootPropertyName = persister.getSubclassPropertyName( propertyNumber ); int pos = fullPath.lastIndexOf( rootPropertyName ); String relativePropertyPath = pos >= 0 ? fullPath.substring( pos ) : rootPropertyName; String fetchRole = persister.getEntityName() + "." + relativePropertyPath; Iterator profiles = getLoadQueryInfluencers().getEnabledFetchProfileNames().iterator(); while ( profiles.hasNext() ) { final String profileName = ( String ) profiles.next(); final FetchProfile profile = getFactory().getFetchProfile( profileName ); final Fetch fetch = profile.getFetchByRole( fetchRole ); if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) { return true; } } return false; }
/** * Use the discriminator, to narrow the select to instances * of the queried subclass, also applying any filters. */ protected String getWhereFragment() throws MappingException { return super.getWhereFragment() + ( (Queryable) getPersister() ).filterFragment( getAlias(), getLoadQueryInfluencers().getEnabledFilters() ); }