Java Code Examples for org.hibernate.sql.JoinFragment#addJoins()

The following examples show how to use org.hibernate.sql.JoinFragment#addJoins() . 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: OuterJoinableAssociation.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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 )
	);
}
 
Example 2
Source File: OuterJoinableAssociation.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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)
	);
}
 
Example 3
Source File: OuterJoinableAssociation.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 )
	);
}
 
Example 4
Source File: JoinSequence.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 )
	);
}
 
Example 5
Source File: OuterJoinableAssociation.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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)
	);
}
 
Example 6
Source File: JoinSequence.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 7
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 8
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 9
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 10
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 11
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 12
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 13
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 14
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 15
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 16
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 17
Source File: JoinSequence.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
	boolean include = isIncluded( alias );
	joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
			joinable.whereJoinFragment( alias, innerJoin, include ) );
}
 
Example 18
Source File: LoadQueryJoinAndFetchProcessor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void addJoins(
		Join join,
		JoinFragment joinFragment,
		Joinable joinable,
		String joinConditions) {
	final String rhsTableAlias = aliasResolutionContext.resolveSqlTableAliasFromQuerySpaceUid(
			join.getRightHandSide().getUid()
	);
	if ( StringHelper.isEmpty( rhsTableAlias ) ) {
		throw new IllegalStateException( "Join's RHS table alias cannot be empty" );
	}

	final String lhsTableAlias = aliasResolutionContext.resolveSqlTableAliasFromQuerySpaceUid(
			join.getLeftHandSide().getUid()
	);
	if ( lhsTableAlias == null ) {
		throw new IllegalStateException( "QuerySpace with that UID was not yet registered in the AliasResolutionContext" );
	}

	String otherConditions = join.getAnyAdditionalJoinConditions( rhsTableAlias );
	if ( !StringHelper.isEmpty( otherConditions ) && !StringHelper.isEmpty( joinConditions ) ) {
		otherConditions += " and " + joinConditions;
	}
	else if ( !StringHelper.isEmpty( joinConditions ) ) {
		otherConditions = joinConditions;
	}

	// add join fragments from the collection table -> element entity table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	final String additionalJoinConditions = resolveAdditionalJoinCondition(
			rhsTableAlias,
			otherConditions,
			joinable,
			getJoinedAssociationTypeOrNull( join )
	);

	String[] joinColumns = join.resolveAliasedLeftHandSideJoinConditionColumns( lhsTableAlias );
	if ( joinColumns.length == 0 ) {
		// When no columns are available, this is a special join that involves multiple subtypes
		AbstractEntityPersister persister = (AbstractEntityPersister) ( (EntityQuerySpace) join.getLeftHandSide() ).getEntityPersister();

		String[][] polyJoinColumns = persister.getPolymorphicJoinColumns(
				lhsTableAlias,
				( (JoinDefinedByMetadata) join ).getJoinedPropertyName()
		);

		joinFragment.addJoin(
				joinable.getTableName(),
				rhsTableAlias,
				polyJoinColumns,
				join.resolveNonAliasedRightHandSideJoinConditionColumns(),
				join.isRightHandSideRequired() ? JoinType.INNER_JOIN : JoinType.LEFT_OUTER_JOIN,
				additionalJoinConditions
		);
	}
	else {
		joinFragment.addJoin(
				joinable.getTableName(),
				rhsTableAlias,
				joinColumns,
				join.resolveNonAliasedRightHandSideJoinConditionColumns(),
				join.isRightHandSideRequired() ? JoinType.INNER_JOIN : JoinType.LEFT_OUTER_JOIN,
				additionalJoinConditions
		);
	}
	joinFragment.addJoins(
			joinable.fromJoinFragment( rhsTableAlias, false, true ),
			joinable.whereJoinFragment( rhsTableAlias, false, true )
	);
}