org.hibernate.sql.QueryJoinFragment Java Examples
The following examples show how to use
org.hibernate.sql.QueryJoinFragment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JoinSequence.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public JoinFragment toJoinFragment( Map enabledFilters, boolean includeExtraJoins, String withClauseFragment, String withClauseJoinAlias) throws MappingException { QueryJoinFragment joinFragment = new QueryJoinFragment( factory.getDialect(), useThetaStyle ); if ( rootJoinable != null ) { joinFragment.addCrossJoin( rootJoinable.getTableName(), rootAlias ); String filterCondition = rootJoinable.filterFragment( rootAlias, enabledFilters ); // JoinProcessor needs to know if the where clause fragment came from a dynamic filter or not so it // can put the where clause fragment in the right place in the SQL AST. 'hasFilterCondition' keeps track // of that fact. joinFragment.setHasFilterCondition( joinFragment.addCondition( filterCondition ) ); if (includeExtraJoins) { //TODO: not quite sure about the full implications of this! addExtraJoins( joinFragment, rootAlias, rootJoinable, true ); } } Joinable last = rootJoinable; for ( int i = 0; i < joins.size(); i++ ) { Join join = ( Join ) joins.get( i ); String on = join.getAssociationType().getOnCondition( join.getAlias(), factory, enabledFilters ); String condition = null; if ( last != null && isManyToManyRoot( last ) && ( ( QueryableCollection ) last ).getElementType() == join.getAssociationType() ) { // the current join represents the join between a many-to-many association table // and its "target" table. Here we need to apply any additional filters // defined specifically on the many-to-many String manyToManyFilter = ( ( QueryableCollection ) last ) .getManyToManyFilterFragment( join.getAlias(), enabledFilters ); condition = "".equals( manyToManyFilter ) ? on : "".equals( on ) ? manyToManyFilter : on + " and " + manyToManyFilter; } else { condition = on; } if ( withClauseFragment != null ) { if ( join.getAlias().equals( withClauseJoinAlias ) ) { condition += " and " + withClauseFragment; } } joinFragment.addJoin( join.getJoinable().getTableName(), join.getAlias(), join.getLHSColumns(), JoinHelper.getRHSColumnNames( join.getAssociationType(), factory ), join.joinType, condition ); if (includeExtraJoins) { //TODO: not quite sure about the full implications of this! addExtraJoins( joinFragment, join.getAlias(), join.getJoinable(), join.joinType == JoinFragment.INNER_JOIN ); } last = join.getJoinable(); } if ( next != null ) { joinFragment.addFragment( next.toJoinFragment( enabledFilters, includeExtraJoins ) ); } joinFragment.addCondition( conditions.toString() ); if ( isFromPart ) joinFragment.clearWherePart(); return joinFragment; }