FileDocCategorySizeDatePackage
QueryJoinFragment.javaAPI DocHibernate 3.2.53511Sun Dec 05 10:20:22 GMT 2004org.hibernate.sql

QueryJoinFragment

public class QueryJoinFragment extends JoinFragment
A join that appears in a translated HQL query
author
Gavin King

Fields Summary
private StringBuffer
afterFrom
private StringBuffer
afterWhere
private org.hibernate.dialect.Dialect
dialect
private boolean
useThetaStyleInnerJoins
Constructors Summary
public QueryJoinFragment(org.hibernate.dialect.Dialect dialect, boolean useThetaStyleInnerJoins)


	     
		this.dialect = dialect;
		this.useThetaStyleInnerJoins = useThetaStyleInnerJoins;
	
Methods Summary
public voidaddCondition(java.lang.String alias, java.lang.String[] fkColumns, java.lang.String[] pkColumns)

		for ( int j = 0; j < fkColumns.length; j++ ) {
			afterWhere.append( " and " )
					.append( fkColumns[j] )
					.append( '=" )
					.append( alias )
					.append( '." )
					.append( pkColumns[j] );
		}
	
public booleanaddCondition(java.lang.String condition)
Add the condition string to the join fragment.

param
condition
return
true if the condition was added, false if it was already in the fragment.

		// if the condition is not already there...
		if (
				afterFrom.toString().indexOf( condition.trim() ) < 0 &&
				afterWhere.toString().indexOf( condition.trim() ) < 0
		) {
			if ( !condition.startsWith( " and " ) ) {
				afterWhere.append( " and " );
			}
			afterWhere.append( condition );
			return true;
		}
		else {
			return false;
		}
	
public voidaddCondition(java.lang.String alias, java.lang.String[] columns, java.lang.String condition)

		for ( int i = 0; i < columns.length; i++ ) {
			afterWhere.append( " and " )
					.append( alias )
					.append( '." )
					.append( columns[i] )
					.append( condition );
		}
	
public voidaddCrossJoin(java.lang.String tableName, java.lang.String alias)

		afterFrom.append( ", " )
				.append( tableName )
				.append( ' " )
				.append( alias );
	
public voidaddFromFragmentString(java.lang.String fromFragmentString)

		afterFrom.append( fromFragmentString );
	
public voidaddJoin(java.lang.String tableName, java.lang.String alias, java.lang.String[] fkColumns, java.lang.String[] pkColumns, int joinType)

		addJoin( tableName, alias, alias, fkColumns, pkColumns, joinType, null );
	
public voidaddJoin(java.lang.String tableName, java.lang.String alias, java.lang.String[] fkColumns, java.lang.String[] pkColumns, int joinType, java.lang.String on)

		addJoin( tableName, alias, alias, fkColumns, pkColumns, joinType, on );
	
private voidaddJoin(java.lang.String tableName, java.lang.String alias, java.lang.String concreteAlias, java.lang.String[] fkColumns, java.lang.String[] pkColumns, int joinType, java.lang.String on)

		if ( !useThetaStyleInnerJoins || joinType != INNER_JOIN ) {
			JoinFragment jf = dialect.createOuterJoinFragment();
			jf.addJoin( tableName, alias, fkColumns, pkColumns, joinType, on );
			addFragment( jf );
		}
		else {
			addCrossJoin( tableName, alias );
			addCondition( concreteAlias, fkColumns, pkColumns );
			addCondition( on );
		}
	
public voidaddJoins(java.lang.String fromFragment, java.lang.String whereFragment)

		afterFrom.append( fromFragment );
		afterWhere.append( whereFragment );
	
public voidclearWherePart()

		afterWhere.setLength( 0 );
	
public JoinFragmentcopy()

		QueryJoinFragment copy = new QueryJoinFragment( dialect, useThetaStyleInnerJoins );
		copy.afterFrom = new StringBuffer( afterFrom.toString() );
		copy.afterWhere = new StringBuffer( afterWhere.toString() );
		return copy;
	
public java.lang.StringtoFromFragmentString()

		return afterFrom.toString();
	
public java.lang.StringtoWhereFragmentString()

		return afterWhere.toString();