FileDocCategorySizeDatePackage
ANSIJoinFragment.javaAPI DocHibernate 3.2.52672Sun Dec 05 08:04:22 GMT 2004org.hibernate.sql

ANSIJoinFragment

public class ANSIJoinFragment extends JoinFragment
An ANSI-style join
author
Gavin King

Fields Summary
private StringBuffer
buffer
private StringBuffer
conditions
Constructors Summary
Methods Summary
public booleanaddCondition(java.lang.String condition)

		return addCondition(conditions, condition);
	
public voidaddCondition(java.lang.String alias, java.lang.String[] columns, java.lang.String condition)

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

		throw new UnsupportedOperationException();

	
public voidaddCrossJoin(java.lang.String tableName, java.lang.String alias)

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

		buffer.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, 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)

		String joinString;
		switch (joinType) {
			case INNER_JOIN:
				joinString = " inner join ";
				break;
			case LEFT_OUTER_JOIN:
				joinString = " left outer join ";
				break;
			case RIGHT_OUTER_JOIN:
				joinString = " right outer join ";
				break;
			case FULL_JOIN:
				joinString = " full outer join ";
				break;
			default:
				throw new AssertionFailure("undefined join type");
		}

		buffer.append(joinString)
			.append(tableName)
			.append(' ")
			.append(alias)
			.append(" on ");


		for ( int j=0; j<fkColumns.length; j++) {
			/*if ( fkColumns[j].indexOf('.')<1 ) {
				throw new AssertionFailure("missing alias");
			}*/
			buffer.append( fkColumns[j] )
				.append('=")
				.append(alias)
				.append('.")
				.append( pkColumns[j] );
			if ( j<fkColumns.length-1 ) buffer.append(" and ");
		}

		addCondition(buffer, on);

	
public voidaddJoins(java.lang.String fromFragment, java.lang.String whereFragment)

		buffer.append(fromFragment);
		//where fragment must be empty!
	
public JoinFragmentcopy()

		ANSIJoinFragment copy = new ANSIJoinFragment();
		copy.buffer = new StringBuffer( buffer.toString() );
		return copy;
	
public java.lang.StringtoFromFragmentString()

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

		return conditions.toString();