public class UnionStatementGenerator extends AbstractStatementGenerator
Modifier and Type | Field and Description |
---|---|
static String |
NUC_TYPE_COLUMN
Name of column added when using "selectNucleusType"
|
candidateTable, candidateTableAlias, candidateTableGroupName, candidateType, clr, includeSubclasses, parentStmt, storeMgr
OPTION_ALLOW_NULLS, OPTION_RESTRICT_DISCRIM, OPTION_SELECT_NUCLEUS_TYPE
Constructor and Description |
---|
UnionStatementGenerator(RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr,
Class candidateType,
boolean includeSubclasses,
DatastoreIdentifier candidateTableAlias,
String candidateTableGroupName)
Constructor using the candidateTable as the primary table.
|
UnionStatementGenerator(RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr,
Class candidateType,
boolean includeSubclasses,
DatastoreIdentifier candidateTableAlias,
String candidateTableGroupName,
Table joinTable,
DatastoreIdentifier joinTableAlias,
JavaTypeMapping joinElementMapping)
Constructor using a join table as the primary table.
|
Modifier and Type | Method and Description |
---|---|
protected SQLStatement |
getSQLStatementForCandidate(String className)
Convenience method to return the SQLStatement for a particular class.
|
protected SQLStatement |
getSQLStatementForCandidateViaJoin(String className)
Convenience method to return the SQLStatement for a particular class selecting a join table.
|
SQLStatement |
getStatement()
Accessor for the SQL Statement for the candidate [+ subclasses].
|
void |
setParentStatement(SQLStatement stmt)
Method to set the parent statement.
|
hasOption, setOption, unsetOption
public static final String NUC_TYPE_COLUMN
public UnionStatementGenerator(RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr, Class candidateType, boolean includeSubclasses, DatastoreIdentifier candidateTableAlias, String candidateTableGroupName)
SELECT ['mydomain.A' AS NUCLEUS_TYPE] FROM A THIS LEFT OUTER JOIN A1 SUBELEMENT0 ON SUBELEMENT0.A1_ID = THIS.A_ID LEFT OUTER JOIN A1 SUBELEMENT1 ON SUBELEMENT0.A2_ID = THIS.A_ID WHERE SUBELEMENT0.A1_ID IS NULL AND SUBELEMENT0.A2_ID IS NULL UNION SELECT ['mydomain.A1' AS NUCLEUS_TYPE] FROM A THIS INNER JOIN A1 'ELEMENT' ON 'ELEMENT'.A1_ID = THIS.A_ID UNION SELECT ['mydomain.A2' AS NUCLEUS_TYPE] FROM A THIS INNER JOIN A2 'ELEMENT' ON 'ELEMENT'.A2_ID = THIS.A_IDSo the first part of the UNION returns the objects just present in the A table, whilst the second part returns those just in table A1, and the third part returns those just in table A2.
storeMgr
- the store managerclr
- ClassLoader resolvercandidateType
- the candidate that we are looking forincludeSubclasses
- if the subclasses of the candidate should be included in the resultcandidateTableAlias
- Alias to use for the candidate table (optional)candidateTableGroupName
- Name of the table group for the candidate(s) (optional)public UnionStatementGenerator(RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr, Class candidateType, boolean includeSubclasses, DatastoreIdentifier candidateTableAlias, String candidateTableGroupName, Table joinTable, DatastoreIdentifier joinTableAlias, JavaTypeMapping joinElementMapping)
SELECT ['mydomain.B' AS NUCLEUS_TYPE] FROM A_B T0 INNER JOIN B T1 ON T0.B_ID_EID = T1.B_ID LEFT OUTER JOIN B1 T2 ON T2.B1_ID = T0.B_ID_EID LEFT OUTER JOIN B2 T3 ON T3.B2_ID = T0.B_ID_EID WHERE T2.B1_ID IS NULL AND T3.B2_ID IS NULL UNION SELECT ['mydomain.B1' AS NUCLEUS_TYPE] FROM A_B THIS INNER JOIN B T1 ON T1.B_ID = T0.B_ID_EID INNER JOIN B1 T2 ON T2.B1_ID = T1.B_ID UNION SELECT ['mydomain.A2' AS NUCLEUS_TYPE] FROM A_B THIS INNER JOIN B T1 ON T1.B_ID = T0.B_ID_EID INNER JOIN B2 T2 ON T2.B2_ID = T1.B_IDSo the first part of the UNION returns the objects just present in the B table, whilst the second part returns those just in table B1, and the third part returns those just in table B2. When we have a join table collection we MUST select the join table since this then caters for the situation of having null elements (if we had selected the root element table we wouldn't know if there was a null element in the collection).
storeMgr
- the store managerclr
- ClassLoader resolvercandidateType
- the candidate that we are looking forincludeSubclasses
- if the subclasses of the candidate should be included in the resultcandidateTableAlias
- Alias to use for the candidate table (optional)candidateTableGroupName
- Name of the table group for the candidate(s) (optional)joinTable
- Join table linking owner to elementsjoinTableAlias
- any alias to use for the join table in the SQLjoinElementMapping
- Mapping in the join table to link to the elementpublic void setParentStatement(SQLStatement stmt)
StatementGenerator
stmt
- The parent statementpublic SQLStatement getStatement()
protected SQLStatement getSQLStatementForCandidate(String className)
className
- The class name to generate the statement forprotected SQLStatement getSQLStatementForCandidateViaJoin(String className)
className
- The class name to generate the statement forCopyright © 2015. All rights reserved.