use of org.hibernate.sql.SelectFragment in project hibernate-orm by hibernate.
the class AbstractEntityPersister method propertySelectFragmentFragment.
public SelectFragment propertySelectFragmentFragment(String tableAlias, String suffix, boolean allProperties) {
SelectFragment select = new SelectFragment().setSuffix(suffix).setUsedAliases(getIdentifierAliases());
int[] columnTableNumbers = getSubclassColumnTableNumberClosure();
String[] columnAliases = getSubclassColumnAliasClosure();
String[] columnReaderTemplates = getSubclassColumnReaderTemplateClosure();
for (int i = 0; i < getSubclassColumnClosure().length; i++) {
boolean selectable = (allProperties || !subclassColumnLazyClosure[i]) && !isSubclassTableSequentialSelect(columnTableNumbers[i]) && subclassColumnSelectableClosure[i];
if (selectable) {
String subalias = generateTableAlias(tableAlias, columnTableNumbers[i]);
select.addColumnTemplate(subalias, columnReaderTemplates[i], columnAliases[i]);
}
}
int[] formulaTableNumbers = getSubclassFormulaTableNumberClosure();
String[] formulaTemplates = getSubclassFormulaTemplateClosure();
String[] formulaAliases = getSubclassFormulaAliasClosure();
for (int i = 0; i < getSubclassFormulaTemplateClosure().length; i++) {
boolean selectable = (allProperties || !subclassFormulaLazyClosure[i]) && !isSubclassTableSequentialSelect(formulaTableNumbers[i]);
if (selectable) {
String subalias = generateTableAlias(tableAlias, formulaTableNumbers[i]);
select.addFormula(subalias, formulaTemplates[i], formulaAliases[i]);
}
}
if (entityMetamodel.hasSubclasses()) {
addDiscriminatorToSelect(select, tableAlias, suffix);
}
if (hasRowId()) {
select.addColumn(tableAlias, rowIdName, ROWID_ALIAS);
}
return select;
}
use of org.hibernate.sql.SelectFragment in project hibernate-orm by hibernate.
the class AbstractEntityPersister method createSelect.
protected SelectFragment createSelect(final int[] subclassColumnNumbers, final int[] subclassFormulaNumbers) {
SelectFragment selectFragment = new SelectFragment();
int[] columnTableNumbers = getSubclassColumnTableNumberClosure();
String[] columnAliases = getSubclassColumnAliasClosure();
String[] columnReaderTemplates = getSubclassColumnReaderTemplateClosure();
for (int i = 0; i < subclassColumnNumbers.length; i++) {
int columnNumber = subclassColumnNumbers[i];
if (subclassColumnSelectableClosure[columnNumber]) {
final String subalias = generateTableAlias(getRootAlias(), columnTableNumbers[columnNumber]);
selectFragment.addColumnTemplate(subalias, columnReaderTemplates[columnNumber], columnAliases[columnNumber]);
}
}
int[] formulaTableNumbers = getSubclassFormulaTableNumberClosure();
String[] formulaTemplates = getSubclassFormulaTemplateClosure();
String[] formulaAliases = getSubclassFormulaAliasClosure();
for (int i = 0; i < subclassFormulaNumbers.length; i++) {
int formulaNumber = subclassFormulaNumbers[i];
final String subalias = generateTableAlias(getRootAlias(), formulaTableNumbers[formulaNumber]);
selectFragment.addFormula(subalias, formulaTemplates[formulaNumber], formulaAliases[formulaNumber]);
}
return selectFragment;
}
use of org.hibernate.sql.SelectFragment in project hibernate-orm by hibernate.
the class MapEntryNode method determineValueSelectExpressions.
private void determineValueSelectExpressions(QueryableCollection collectionPersister, List selections) {
AliasGenerator aliasGenerator = new LocalAliasGenerator(1);
appendSelectExpressions(collectionPersister.getElementColumnNames(), selections, aliasGenerator);
Type valueType = collectionPersister.getElementType();
if (valueType.isAssociationType()) {
EntityType valueEntityType = (EntityType) valueType;
Queryable valueEntityPersister = (Queryable) sfi().getEntityPersister(valueEntityType.getAssociatedEntityName(sfi()));
SelectFragment fragment = valueEntityPersister.propertySelectFragmentFragment(elementTableAlias(), null, false);
appendSelectExpressions(fragment, selections, aliasGenerator);
}
}
use of org.hibernate.sql.SelectFragment in project hibernate-orm by hibernate.
the class MapEntryNode method determineKeySelectExpressions.
private void determineKeySelectExpressions(QueryableCollection collectionPersister, List selections) {
AliasGenerator aliasGenerator = new LocalAliasGenerator(0);
appendSelectExpressions(collectionPersister.getIndexColumnNames(), selections, aliasGenerator);
Type keyType = collectionPersister.getIndexType();
if (keyType.isEntityType()) {
MapKeyEntityFromElement mapKeyEntityFromElement = findOrAddMapKeyEntityFromElement(collectionPersister);
Queryable keyEntityPersister = mapKeyEntityFromElement.getQueryable();
SelectFragment fragment = keyEntityPersister.propertySelectFragmentFragment(mapKeyEntityFromElement.getTableAlias(), null, false);
appendSelectExpressions(fragment, selections, aliasGenerator);
}
}
Aggregations