Java Code Examples for org.hibernate.persister.entity.Joinable#isCollection()
The following examples show how to use
org.hibernate.persister.entity.Joinable#isCollection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicCollectionPersister.java From lams with GNU General Public License v2.0 | 6 votes |
public String selectFragment( Joinable rhs, String rhsAlias, String lhsAlias, String entitySuffix, String collectionSuffix, boolean includeCollectionColumns) { // we need to determine the best way to know that two joinables // represent a single many-to-many... if ( rhs != null && isManyToMany() && !rhs.isCollection() ) { AssociationType elementType = ( (AssociationType) getElementType() ); if ( rhs.equals( elementType.getAssociatedJoinable( getFactory() ) ) ) { return manyToManySelectFragment( rhs, rhsAlias, lhsAlias, collectionSuffix ); } } return includeCollectionColumns ? selectFragment( lhsAlias, collectionSuffix ) : ""; }
Example 2
Source File: BasicCollectionPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public String selectFragment( Joinable rhs, String rhsAlias, String lhsAlias, String entitySuffix, String collectionSuffix, boolean includeCollectionColumns) { // we need to determine the best way to know that two joinables // represent a single many-to-many... if ( rhs != null && isManyToMany() && !rhs.isCollection() ) { AssociationType elementType = ( ( AssociationType ) getElementType() ); if ( rhs.equals( elementType.getAssociatedJoinable( getFactory() ) ) ) { return manyToManySelectFragment( rhs, rhsAlias, lhsAlias, collectionSuffix ); } } return includeCollectionColumns ? selectFragment( lhsAlias, collectionSuffix ) : ""; }
Example 3
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 4
Source File: JoinSequence.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 5
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 6
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 7
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 8
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 9
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 10
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 11
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 12
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 13
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 14
Source File: JoinSequence.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { QueryableCollection persister = ( QueryableCollection ) joinable; return persister.isManyToMany(); } return false; }
Example 15
Source File: JoinSequence.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("SimplifiableIfStatement") private boolean isManyToManyRoot(Joinable joinable) { if ( joinable != null && joinable.isCollection() ) { return ( (QueryableCollection) joinable ).isManyToMany(); } return false; }
Example 16
Source File: EntityBasedAssociationAttribute.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public AssociationKey getAssociationKey() { final AssociationType type = getType(); if ( type.isAnyType() ) { return new AssociationKey( JoinHelper.getLHSTableName( type, attributeNumber(), (OuterJoinLoadable) getSource() ), JoinHelper.getLHSColumnNames( type, attributeNumber(), 0, (OuterJoinLoadable) getSource(), sessionFactory() ) ); } final Joinable joinable = type.getAssociatedJoinable( sessionFactory() ); if ( type.getForeignKeyDirection() == ForeignKeyDirection.FROM_PARENT ) { final String lhsTableName; final String[] lhsColumnNames; if ( joinable.isCollection() ) { final QueryableCollection collectionPersister = (QueryableCollection) joinable; lhsTableName = collectionPersister.getTableName(); lhsColumnNames = collectionPersister.getElementColumnNames(); } else { final OuterJoinLoadable entityPersister = (OuterJoinLoadable) source(); lhsTableName = getLHSTableName( type, attributeNumber(), entityPersister ); lhsColumnNames = getLHSColumnNames( type, attributeNumber(), entityPersister, sessionFactory() ); } return new AssociationKey( lhsTableName, lhsColumnNames ); } else { return new AssociationKey( joinable.getTableName(), getRHSColumnNames( type, sessionFactory() ) ); } }
Example 17
Source File: JoinWalker.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Add on association (one-to-one, many-to-one, or a collection) to a list * of associations to be fetched by outerjoin */ private void addAssociationToJoinTree( final AssociationType type, final String[] aliasedLhsColumns, final String alias, final PropertyPath path, final int currentDepth, final JoinType joinType) throws MappingException { Joinable joinable = type.getAssociatedJoinable( getFactory() ); // important to generate alias based on size of association collection // *before* adding this join to that collection String subalias = generateTableAlias( associations.size() + 1, path, joinable ); // NOTE : it should be fine to continue to pass only filters below // (instead of LoadQueryInfluencers) since "from that point on" we // only need to worry about restrictions (and not say adding more // joins) OuterJoinableAssociation assoc = new OuterJoinableAssociation( path, type, alias, aliasedLhsColumns, subalias, joinType, joinable.consumesEntityAlias() ? getWithClause( path ) : "", hasRestriction( path ), getFactory(), loadQueryInfluencers.getEnabledFilters() ); assoc.validateJoin( path.getFullPath() ); associations.add( assoc ); int nextDepth = currentDepth + 1; // path = ""; if ( !joinable.isCollection() ) { if ( joinable instanceof OuterJoinLoadable ) { walkEntityTree( (OuterJoinLoadable) joinable, subalias, path, nextDepth ); } } else { if ( joinable instanceof QueryableCollection ) { walkCollectionTree( (QueryableCollection) joinable, subalias, path, nextDepth ); } } }
Example 18
Source File: IgnitePropertyHelper.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 4 votes |
/** * Returns the {@link PropertyIdentifier} for the given property path. * * In passing, it creates all the necessary aliases for embedded/associations. * * @param path the path to the property * @param targetEntityType the type of the entity * @return the {@link PropertyIdentifier} */ PropertyIdentifier getPropertyIdentifier(PropertyPath path, String targetEntityType) { // we analyze the property path to find all the associations/embedded // which are in the way and create proper aliases for them List<String> propertyPath = path.getNodeNamesWithoutAlias(); String entityAlias; boolean isLastElementAssociation = true; if ( path.getFirstNode().isAlias() ) { entityAlias = path.getFirstNode().getName(); } else { entityAlias = findAliasForType( targetEntityType ); } String propertyEntityType = entityNameByAlias.get( entityAlias ); if ( propertyEntityType == null ) { propertyEntityType = targetEntityType; } String propertyAlias = entityAlias; String propertyName; List<String> currentPropertyPath = new ArrayList<>(); List<String> lastAssociationPath = new ArrayList<>(); OgmEntityPersister currentPersister = getPersister( propertyEntityType ); OgmEntityPersister predPersister = currentPersister; String predJoinAlias = entityAlias; for ( String property : propertyPath ) { currentPropertyPath.add( property ); Type currentPropertyType = getPropertyType( propertyEntityType, Collections.singletonList( property ) ); if ( currentPropertyType.isAssociationType() ) { propertyEntityType = currentPropertyType.getName(); currentPersister = getPersister( propertyEntityType ); AssociationType associationPropertyType = (AssociationType) currentPropertyType; Joinable associatedJoinable = associationPropertyType.getAssociatedJoinable( getSessionFactory() ); if ( associatedJoinable.isCollection() && ( (OgmCollectionPersister) associatedJoinable ).getType().isComponentType() ) { // we have a collection of embedded throw new NotYetImplementedException( "Query with collection of embeddables" ); // propertyAlias = aliasResolver.createAliasForEmbedded( entityAlias, currentPropertyPath, optionalMatch ); } else { // last in path? - no need for join if ( currentPropertyPath.size() == propertyPath.size() ) { propertyName = getColumnName( predPersister.getEntityType().getName(), Collections.singletonList( property ) ); return new PropertyIdentifier( predJoinAlias, propertyName ); } // else, we register an implicit join lastAssociationPath.add( property ); throw new NotYetImplementedException( "Query on associated property" ); // predPersister = currentPersister; // isLastElementAssociation = true; } } else if ( currentPropertyType.isComponentType() && !isIdProperty( currentPersister, propertyPath.subList( lastAssociationPath.size(), propertyPath.size() ) ) ) { // we are in the embedded case and the embedded is not the id of the entity (the id is stored as normal // properties) String embeddedProperty = String.join( ".", propertyPath.subList( lastAssociationPath.size(), propertyPath.size() ) ); String[] columns = currentPersister.getPropertyColumnNames( embeddedProperty ); if ( columns.length > 1 ) { throw new NotYetImplementedException( "Query with composite-ID association" ); } return new PropertyIdentifier( propertyAlias, columns[0] ); } else { isLastElementAssociation = false; } } if ( isLastElementAssociation ) { // even the last element is an association, we need to find a suitable identifier property propertyName = getPersister( propertyEntityType ).getIdentifierPropertyName(); } else { // the last element is a property so we can build the rest with this property propertyName = getColumnName( propertyEntityType, propertyPath.subList( lastAssociationPath.size(), propertyPath.size() ) ); } return new PropertyIdentifier( predJoinAlias, propertyName ); }
Example 19
Source File: JoinWalker.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Add on association (one-to-one, many-to-one, or a collection) to a list * of associations to be fetched by outerjoin */ private void addAssociationToJoinTree( final AssociationType type, final String[] aliasedLhsColumns, final String alias, final String path, final int currentDepth, final int joinType) throws MappingException { Joinable joinable = type.getAssociatedJoinable( getFactory() ); String subalias = generateTableAlias( associations.size()+1, //before adding to collection! path, joinable ); OuterJoinableAssociation assoc = new OuterJoinableAssociation( type, alias, aliasedLhsColumns, subalias, joinType, getFactory(), enabledFilters ); assoc.validateJoin(path); associations.add(assoc); int nextDepth = currentDepth+1; if ( !joinable.isCollection() ) { if (joinable instanceof OuterJoinLoadable) { walkEntityTree( (OuterJoinLoadable) joinable, subalias, path, nextDepth ); } } else { if (joinable instanceof QueryableCollection) { walkCollectionTree( (QueryableCollection) joinable, subalias, path, nextDepth ); } } }
Example 20
Source File: CriteriaJoinWalker.java From lams with GNU General Public License v2.0 | 4 votes |
@Override protected String generateTableAlias(int n, PropertyPath path, Joinable joinable) { // TODO: deal with side-effects (changes to includeInResultRowList, userAliasList, resultTypeList)!!! // for collection-of-entity, we are called twice for given "path" // once for the collection Joinable, once for the entity Joinable. // the second call will/must "consume" the alias + perform side effects according to consumesEntityAlias() // for collection-of-other, however, there is only one call // it must "consume" the alias + perform side effects, despite what consumeEntityAlias() return says // // note: the logic for adding to the userAliasList is still strictly based on consumesEntityAlias return value boolean checkForSqlAlias = joinable.consumesEntityAlias(); if ( !checkForSqlAlias && joinable.isCollection() ) { // is it a collection-of-other (component or value) ? CollectionPersister collectionPersister = (CollectionPersister) joinable; Type elementType = collectionPersister.getElementType(); if ( elementType.isComponentType() || !elementType.isEntityType() ) { checkForSqlAlias = true; } } String sqlAlias = null; if ( checkForSqlAlias ) { final Criteria subcriteria = translator.getCriteria( path.getFullPath() ); sqlAlias = subcriteria == null ? null : translator.getSQLAlias( subcriteria ); if ( joinable.consumesEntityAlias() && !translator.hasProjection() ) { includeInResultRowList.add( subcriteria != null && subcriteria.getAlias() != null ); if ( sqlAlias != null ) { if ( subcriteria.getAlias() != null ) { userAliasList.add( subcriteria.getAlias() ); resultTypeList.add( translator.getResultType( subcriteria ) ); } } } } if ( sqlAlias == null ) { sqlAlias = super.generateTableAlias( n + translator.getSQLAliasCount(), path, joinable ); } return sqlAlias; }