PAJES 3.0.21

org.pajes.db.entity
Class JoinScope

java.lang.Object
  extended by org.pajes.db.entity.JoinScope

public class JoinScope
extends java.lang.Object

Creates an ON clause suitable for use in a SQL join.

The clause is built up by applying the and() and or() methods, followed by the appropriate comparison methods (compare(), between() and isNull()). For example:

 JoinScope clause = new JoinScope().join("primaryTable.colA", JoinScope.EQ, "joinTable.colA").and().join("primaryTable.colB", JoinScope.EQ, "joinTable.colB");
 System.out.println(clause.getOnClause());
 

See Also:
Scope

Constructor Summary
JoinScope()
          Creates an ON clause suitable for use with a SQL join.
JoinScope(java.lang.String leftTableAlias)
          Creates an ON clause suitable for use with a SQL join.
JoinScope(java.lang.String leftTableAlias, java.lang.String rightTableAlias)
          Creates an ON clause suitable for use with a SQL join.
 
Method Summary
 JoinScope and()
          Appends an AND statement.
 JoinScope compare(java.lang.String columnName, java.lang.String operator, java.lang.Object value)
          Appends the specified comparison.
 java.lang.String getLeftTableAlias()
          Returns the left table alias.
 java.lang.Object[] getParameters()
          Returns the join parameters that can be substituted into the join clause.
 java.lang.String getRightTableAlias()
          Returns the right table alias.
 boolean isLeftTableAliasUsed()
          Determines whether the alias will be automatically prepended to the leftColumnName in the join(java.lang.String, java.lang.String) methods.
 boolean isRightTableAliasUsed()
          Determines whether the alias will be automatically prepended to the rightColumnName in the join(java.lang.String, java.lang.String) methods.
 JoinScope join(java.lang.String leftColumnName, java.lang.String rightColumnName)
          Appends the specified equality comparison between two columns.
 JoinScope join(java.lang.String leftColumnName, java.lang.String operator, java.lang.String rightColumnName)
          Appends the specified comparison between two columns.
 JoinScope leftBrace()
          Appends a left Brace to begin logical statement grouping.
 JoinScope or()
          Appends an OR statement.
 JoinScope rightBrace()
          Appends a right Brace to end logical statement grouping.
 void setLeftTableAlias(java.lang.String leftTableAlias)
          Sets the left table alias.
 void setLeftTableAliasUsed(boolean leftTableAliasUsed)
          Sets whether the alias will be automatically prepended to the leftColumnName in the join(java.lang.String, java.lang.String) methods.
 void setRightTableAlias(java.lang.String rightTableAlias)
          Sets the right table alias.
 void setRightTableAliasUsed(boolean rightTableAliasUsed)
          Sets whether the alias will be automatically prepended to the rightColumnName in the join(java.lang.String, java.lang.String) methods.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JoinScope

public JoinScope()
Creates an ON clause suitable for use with a SQL join.


JoinScope

public JoinScope(java.lang.String leftTableAlias)
Creates an ON clause suitable for use with a SQL join.

Parameters:
leftTableAlias - the left table alias.

JoinScope

public JoinScope(java.lang.String leftTableAlias,
                 java.lang.String rightTableAlias)
Creates an ON clause suitable for use with a SQL join.

Parameters:
leftTableAlias - the left table alias.
rightTableAlias - the right table alias.
Method Detail

and

public JoinScope and()
Appends an AND statement. If the Scope has no conditions, the AND is NOT appended!

Returns:
the modified Scope object.

compare

public JoinScope compare(java.lang.String columnName,
                         java.lang.String operator,
                         java.lang.Object value)
Appends the specified comparison.

Parameters:
columnName - the name of the column.
operator - the comparison operator.
value - the comparison value.
Returns:
the modified Scope object.

getLeftTableAlias

public java.lang.String getLeftTableAlias()
Returns the left table alias.

Returns:
the left table alias.

getParameters

public java.lang.Object[] getParameters()
Returns the join parameters that can be substituted into the join clause.

Returns:
an array of the Objects that correspond to the placeholders in the join clause.

getRightTableAlias

public java.lang.String getRightTableAlias()
Returns the right table alias.

Returns:
the right table alias.

isLeftTableAliasUsed

public boolean isLeftTableAliasUsed()
Determines whether the alias will be automatically prepended to the leftColumnName in the join(java.lang.String, java.lang.String) methods.

Returns:
true if the left table alias will be automtically used.

isRightTableAliasUsed

public boolean isRightTableAliasUsed()
Determines whether the alias will be automatically prepended to the rightColumnName in the join(java.lang.String, java.lang.String) methods.

Returns:
true if the right table alias will be automtically used.

join

public JoinScope join(java.lang.String leftColumnName,
                      java.lang.String rightColumnName)
Appends the specified equality comparison between two columns.

Parameters:
leftColumnName - the name of the column on the left of the comparison.
rightColumnName - the name of the column on the right of the comparison.
Returns:
the modified Scope object.

join

public JoinScope join(java.lang.String leftColumnName,
                      java.lang.String operator,
                      java.lang.String rightColumnName)
Appends the specified comparison between two columns.

Parameters:
leftColumnName - the name of the column on the left of the comparison.
operator - the comparison operator.
rightColumnName - the name of the column on the right of the comparison.
Returns:
the modified Scope object.

leftBrace

public JoinScope leftBrace()
Appends a left Brace to begin logical statement grouping.

Returns:
the modified Scope object.

or

public JoinScope or()
Appends an OR statement. If the Scope has no conditions, the OR is NOT appended!

Returns:
the modified Scope object.

rightBrace

public JoinScope rightBrace()
Appends a right Brace to end logical statement grouping.

Returns:
the modified Scope object.

setLeftTableAlias

public void setLeftTableAlias(java.lang.String leftTableAlias)
Sets the left table alias. Note that setting the alias will automatically set whether it is used or not

Parameters:
leftTableAlias - the left table alias.

setLeftTableAliasUsed

public void setLeftTableAliasUsed(boolean leftTableAliasUsed)
Sets whether the alias will be automatically prepended to the leftColumnName in the join(java.lang.String, java.lang.String) methods.

Parameters:
leftTableAliasUsed - true if the left table alias will be automtically used.

setRightTableAlias

public void setRightTableAlias(java.lang.String rightTableAlias)
Sets the right table alias. Note that setting the alias will automatically set whether it is used or not

Parameters:
rightTableAlias - The rightTableAlias to set

setRightTableAliasUsed

public void setRightTableAliasUsed(boolean rightTableAliasUsed)
Sets whether the alias will be automatically prepended to the rightColumnName in the join(java.lang.String, java.lang.String) methods.

Parameters:
rightTableAliasUsed - true if the right table alias will be automtically used.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

PAJES 3.0.21

Copyright © 1998-2007 Viridian Pty Limited. All Rights Reserved.