Module org.tentackle.persistence
Package org.tentackle.persist
Class Join<T extends PersistentDomainObject<T>,J extends PersistentDomainObject<J>>
java.lang.Object
org.tentackle.persist.Join<T,J>
- Type Parameters:
T- the PDO type holding the relation to the joined PDOJ- the joined PDO type
public class Join<T extends PersistentDomainObject<T>,J extends PersistentDomainObject<J>>
extends Object
PDO join.
Joins two PDOs within the same select.
Used by eager joins and explicit domain-driven joins.
Works for composite and non-composite relations.
- Author:
- harald
-
Constructor Summary
ConstructorsConstructorDescriptionJoin(org.tentackle.sql.JoinType type, String columnName, String joinedColumnName, Class<J> joinedClass, String joinAlias, String extraSql, BiConsumer<T, J> joiner) Creates a join.Join(org.tentackle.sql.JoinType type, String columnName, String joinedColumnName, Class<J> joinedClass, String joinAlias, BiConsumer<T, J> joiner) Creates a join. -
Method Summary
Modifier and TypeMethodDescriptionAdds a cascaded join.createJoinedPdo(T pdo) Creates a new PDO to join to given pdo.Gets the column name of the PDO.Gets optional SQL code.Gets the alias of the joined PDO.Gets the joined PDO class.Gets the joined column name.BiConsumer<T, J> Gets the joiner.getJoins()Gets the cascaded joins.org.tentackle.sql.JoinTypegetType()Gets the join type.voidInitializes the join.booleanReturns whether an extra ID-alias must be added to the joined select statement.booleanReturns whether joined to list or object.Joins a pdo with another pdo.
-
Constructor Details
-
Join
public Join(org.tentackle.sql.JoinType type, String columnName, String joinedColumnName, Class<J> joinedClass, String joinAlias, String extraSql, BiConsumer<T, J> joiner) Creates a join.- Parameters:
type- the join typecolumnName- the column name of the PDO (includung table alias!)joinedColumnName- the column name of the joined PDO (includung table alias!)joinedClass- the joined classjoinAlias- the alias of the joined pdoextraSql- optional SQL code (usually a WHERE clause)joiner- the joiner
-
Join
public Join(org.tentackle.sql.JoinType type, String columnName, String joinedColumnName, Class<J> joinedClass, String joinAlias, BiConsumer<T, J> joiner) Creates a join.- Parameters:
type- the join typecolumnName- the column name of the PDO (includung table alias!)joinedColumnName- the column name of the joined PDO (includung table alias!)joinedClass- the joined classjoinAlias- the alias of the joined pdojoiner- the joiner
-
-
Method Details
-
getType
public org.tentackle.sql.JoinType getType()Gets the join type.- Returns:
- the type
-
isListJoin
public boolean isListJoin()Returns whether joined to list or object.- Returns:
- true if to list
-
isExplicitIdAliasRequired
public boolean isExplicitIdAliasRequired()Returns whether an extra ID-alias must be added to the joined select statement. This is true for multi-table inherited object relations.- Returns:
- true if ID alias necessary
-
getColumnName
Gets the column name of the PDO.- Returns:
- the column name
-
getJoinedColumnName
Gets the joined column name.- Returns:
- the column name, "id" if object join, else list join
-
getJoinedClass
Gets the joined PDO class.- Returns:
- the class
-
getJoinAlias
Gets the alias of the joined PDO.- Returns:
- the alias
-
getJoiner
Gets the joiner.- Returns:
- the joiner
-
getExtraSql
Gets optional SQL code.- Returns:
- sql code, null or empty if none
-
addJoin
Adds a cascaded join.- Parameters:
join- the cascaded join- Returns:
- me (to allow fluent style setup)
-
getJoins
Gets the cascaded joins.- Returns:
- the cascaded joins, never null
-
initialize
public void initialize()Initializes the join. -
createJoinedPdo
Creates a new PDO to join to given pdo.- Parameters:
pdo- the pdo to join to- Returns:
- the pdo to join
-
join
Joins a pdo with another pdo.- Parameters:
pdo- the pdo that gets the joinpdoToJoin- the pdo to join, null to finish the joining process- Returns:
- the new or already joined pdo
-