use of org.hibernate.type.CompositeType in project hibernate-orm by hibernate.
the class JoinWalker method walkCompositeElementTree.
/**
* For a composite element, add to a list of associations to be fetched by outerjoin
*/
private void walkCompositeElementTree(final CompositeType compositeType, final String[] cols, final QueryableCollection persister, final String alias, final PropertyPath path, final int currentDepth) throws MappingException {
Type[] types = compositeType.getSubtypes();
String[] propertyNames = compositeType.getPropertyNames();
int begin = 0;
for (int i = 0; i < types.length; i++) {
int length = types[i].getColumnSpan(getFactory());
String[] lhsColumns = ArrayHelper.slice(cols, begin, length);
if (types[i].isAssociationType()) {
AssociationType associationType = (AssociationType) types[i];
// simple, because we can't have a one-to-one or a collection
// (or even a property-ref) in a composite-element:
String[] aliasedLhsColumns = StringHelper.qualify(alias, lhsColumns);
final PropertyPath subPath = path.append(propertyNames[i]);
final boolean[] propertyNullability = compositeType.getPropertyNullability();
final JoinType joinType = getJoinType(associationType, compositeType.getFetchMode(i), subPath, persister.getTableName(), lhsColumns, propertyNullability == null || propertyNullability[i], currentDepth, compositeType.getCascadeStyle(i));
addAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subPath, currentDepth, joinType);
} else if (types[i].isComponentType()) {
final PropertyPath subPath = path.append(propertyNames[i]);
walkCompositeElementTree((CompositeType) types[i], lhsColumns, persister, alias, subPath, currentDepth);
}
begin += length;
}
}
use of org.hibernate.type.CompositeType in project hibernate-orm by hibernate.
the class JoinWalker method walkComponentTree.
/**
* For a component, add to a list of associations to be fetched by outerjoin
*
* @param componentType The component type to be walked.
* @param propertyNumber The property number for the component property (relative to
* persister).
* @param begin todo unknowm
* @param persister The owner of the component property
* @param alias The root alias
* @param path The property access path
* @param currentDepth The current join depth
*
* @throws org.hibernate.MappingException ???
*/
private void walkComponentTree(final CompositeType componentType, final int propertyNumber, int begin, final OuterJoinLoadable persister, final String alias, final PropertyPath path, final int currentDepth) throws MappingException {
Type[] types = componentType.getSubtypes();
String[] propertyNames = componentType.getPropertyNames();
for (int i = 0; i < types.length; i++) {
if (types[i].isAssociationType()) {
AssociationType associationType = (AssociationType) types[i];
String[] aliasedLhsColumns = JoinHelper.getAliasedLHSColumnNames(associationType, alias, propertyNumber, begin, persister, getFactory());
String[] lhsColumns = JoinHelper.getLHSColumnNames(associationType, propertyNumber, begin, persister, getFactory());
String lhsTable = JoinHelper.getLHSTableName(associationType, propertyNumber, persister);
final PropertyPath subPath = path.append(propertyNames[i]);
final boolean[] propertyNullability = componentType.getPropertyNullability();
final JoinType joinType = getJoinType(persister, subPath, propertyNumber, associationType, componentType.getFetchMode(i), componentType.getCascadeStyle(i), lhsTable, lhsColumns, propertyNullability == null || propertyNullability[i], currentDepth);
addAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subPath, currentDepth, joinType);
} else if (types[i].isComponentType()) {
final PropertyPath subPath = path.append(propertyNames[i]);
walkComponentTree((CompositeType) types[i], propertyNumber, begin, persister, alias, subPath, currentDepth);
}
begin += types[i].getColumnSpan(getFactory());
}
}
use of org.hibernate.type.CompositeType in project hibernate-orm by hibernate.
the class AbstractCollectionReference method buildElementGraph.
private CollectionFetchableElement buildElementGraph() {
final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
final Type type = persister.getElementType();
if (type.isAssociationType()) {
if (type.isEntityType()) {
final EntityPersister elementPersister = persister.getFactory().getEntityPersister(((EntityType) type).getAssociatedEntityName());
final ExpandingEntityQuerySpace entityQuerySpace = QuerySpaceHelper.INSTANCE.makeEntityQuerySpace(collectionQuerySpace, elementPersister, CollectionPropertyNames.COLLECTION_ELEMENTS, (EntityType) persister.getElementType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowElementJoin);
return new CollectionFetchableElementEntityGraph(this, entityQuerySpace);
} else if (type.isAnyType()) {
return new CollectionFetchableElementAnyGraph(this);
}
} else if (type.isComponentType()) {
final ExpandingCompositeQuerySpace compositeQuerySpace = QuerySpaceHelper.INSTANCE.makeCompositeQuerySpace(collectionQuerySpace, new CompositePropertyMapping((CompositeType) persister.getElementType(), (PropertyMapping) persister, ""), CollectionPropertyNames.COLLECTION_ELEMENTS, (CompositeType) persister.getElementType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowElementJoin);
return new CollectionFetchableElementCompositeGraph(this, compositeQuerySpace);
}
return null;
}
use of org.hibernate.type.CompositeType in project hibernate-orm by hibernate.
the class EntityQuerySpaceImpl method makeCompositeIdentifierQuerySpace.
@Override
public ExpandingCompositeQuerySpace makeCompositeIdentifierQuerySpace() {
final String compositeQuerySpaceUid = getUid() + "-id";
final ExpandingCompositeQuerySpace rhs = getExpandingQuerySpaces().makeCompositeQuerySpace(compositeQuerySpaceUid, new CompositePropertyMapping((CompositeType) getEntityPersister().getIdentifierType(), (PropertyMapping) getEntityPersister(), getEntityPersister().getIdentifierPropertyName()), canJoinsBeRequired());
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(this, EntityPersister.ENTITY_ID, rhs, canJoinsBeRequired(), (CompositeType) persister.getIdentifierType());
internalGetJoins().add(join);
return rhs;
}
use of org.hibernate.type.CompositeType in project hibernate-orm by hibernate.
the class AbstractCollectionPersister method initCollectionPropertyMap.
private void initCollectionPropertyMap(String aliasName, Type type, String[] columnAliases, String[] columnNames) {
collectionPropertyColumnAliases.put(aliasName, columnAliases);
collectionPropertyColumnNames.put(aliasName, columnNames);
if (type.isComponentType()) {
CompositeType ct = (CompositeType) type;
String[] propertyNames = ct.getPropertyNames();
for (int i = 0; i < propertyNames.length; i++) {
String name = propertyNames[i];
collectionPropertyColumnAliases.put(aliasName + "." + name, columnAliases[i]);
collectionPropertyColumnNames.put(aliasName + "." + name, columnNames[i]);
}
}
}
Aggregations