📄 fromelement.java
字号:
return dereferencedBySubclassProperty || dereferencedBySuperclassProperty; } public String getIdentityColumn() { checkInitialized(); String table = getTableAlias(); if ( table == null ) { throw new IllegalStateException( "No table alias for node " + this ); } String[] cols; String propertyName; if ( getEntityPersister() != null && getEntityPersister().getEntityMetamodel() != null && getEntityPersister().getEntityMetamodel().hasNonIdentifierPropertyNamedId() ) { propertyName = getEntityPersister().getIdentifierPropertyName(); } else { propertyName = EntityPersister.ENTITY_ID; } if ( getWalker().getStatementType() == HqlSqlWalker.SELECT ) { cols = getPropertyMapping( propertyName ).toColumns( table, propertyName ); } else { cols = getPropertyMapping( propertyName ).toColumns( propertyName ); } String result = StringHelper.join( ", ", cols ); return cols.length == 1 ? result : "(" + result + ")"; } public void setCollectionJoin(boolean collectionJoin) { this.collectionJoin = collectionJoin; } public boolean isCollectionJoin() { return collectionJoin; } public void setRole(String role) { this.role = role; } public void setQueryableCollection(QueryableCollection queryableCollection) { elementType.setQueryableCollection( queryableCollection ); } public QueryableCollection getQueryableCollection() { return elementType.getQueryableCollection(); } public void setColumns(String[] columns) { this.columns = columns; } public void setOrigin(FromElement origin, boolean manyToMany) { this.origin = origin; this.manyToMany = manyToMany; origin.addDestination( this ); if ( origin.getFromClause() == this.getFromClause() ) { // TODO: Figure out a better way to get the FROM elements in a proper tree structure. // If this is not the destination of a many-to-many, add it as a child of the origin. if ( manyToMany ) { ASTUtil.appendSibling( origin, this ); } else { if ( !getWalker().isInFrom() && !getWalker().isInSelect() ) { getFromClause().addChild( this ); } else { origin.addChild( this ); } } } else if ( !getWalker().isInFrom() ) { // HHH-276 : implied joins in a subselect where clause - The destination needs to be added // to the destination's from clause. getFromClause().addChild( this ); // Not sure if this is will fix everything, but it works. } else { // Otherwise, the destination node was implied by the FROM clause and the FROM clause processor // will automatically add it in the right place. } } public boolean isManyToMany() { return manyToMany; } private void addDestination(FromElement fromElement) { destinations.add( fromElement ); } public List getDestinations() { return destinations; } public FromElement getOrigin() { return origin; } public FromElement getRealOrigin() { if ( origin == null ) { return null; } if ( origin.getText() == null || "".equals( origin.getText() ) ) { return origin.getRealOrigin(); } return origin; } public Type getPropertyType(String propertyName, String propertyPath) { return elementType.getPropertyType( propertyName, propertyPath ); } public String[] toColumns(String tableAlias, String path, boolean inSelect) { return elementType.toColumns( tableAlias, path, inSelect ); } public String[] toColumns(String tableAlias, String path, boolean inSelect, boolean forceAlias) { return elementType.toColumns( tableAlias, path, inSelect, forceAlias ); } public PropertyMapping getPropertyMapping(String propertyName) { return elementType.getPropertyMapping( propertyName ); } public void setFetch(boolean fetch) { this.fetch = fetch; // Fetch can't be used with scroll() or iterate(). if ( fetch && getWalker().isShallowQuery() ) { throw new QueryException( QueryTranslator.ERROR_CANNOT_FETCH_WITH_ITERATE ); } } public boolean isFetch() { return fetch; } public int getSequence() { return sequence; } public void setFilter(boolean b) { filter = b; } public boolean isFilter() { return filter; } public boolean useFromFragment() { checkInitialized(); // If it's not implied or it is implied and it's a many to many join where the target wasn't found. return !isImplied() || this.useFromFragment; } public void setUseFromFragment(boolean useFromFragment) { this.useFromFragment = useFromFragment; } public boolean useWhereFragment() { return useWhereFragment; } public void setUseWhereFragment(boolean b) { useWhereFragment = b; } public void setCollectionTableAlias(String collectionTableAlias) { this.collectionTableAlias = collectionTableAlias; } public String getCollectionTableAlias() { return collectionTableAlias; } public boolean isCollectionOfValuesOrComponents() { return elementType.isCollectionOfValuesOrComponents(); } public boolean isEntity() { return elementType.isEntity(); } public void setImpliedInFromClause(boolean flag) { throw new UnsupportedOperationException( "Explicit FROM elements can't be implied in the FROM clause!" ); } public boolean isImpliedInFromClause() { return false; // Since this is an explicit FROM element, it can't be implied in the FROM clause. } public void setInProjectionList(boolean inProjectionList) { // Do nothing, eplicit from elements are *always* in the projection list. } public boolean inProjectionList() { return !isImplied() && isFromOrJoinFragment(); } public boolean isFromOrJoinFragment() { return getType() == SqlTokenTypes.FROM_FRAGMENT || getType() == SqlTokenTypes.JOIN_FRAGMENT; } public boolean isAllPropertyFetch() { return isAllPropertyFetch; } public void setAllPropertyFetch(boolean fetch) { isAllPropertyFetch = fetch; } public String getWithClauseFragment() { return withClauseFragment; } public String getWithClauseJoinAlias() { return withClauseJoinAlias; } public void setWithClauseFragment(String withClauseJoinAlias, String withClauseFragment) { this.withClauseJoinAlias = withClauseJoinAlias; this.withClauseFragment = withClauseFragment; } public boolean hasCacheablePersister() { if ( getQueryableCollection() != null ) { return getQueryableCollection().hasCache(); } else { return getQueryable().hasCache(); } } public void handlePropertyBeingDereferenced(Type propertySource, String propertyName) { if ( getQueryableCollection() != null && CollectionProperties.isCollectionProperty( propertyName ) ) { // propertyName refers to something like collection.size... return; } if ( propertySource.isComponentType() ) { // property name is a sub-path of a component... return; } Queryable persister = getQueryable(); if ( persister != null ) { try { Queryable.Declarer propertyDeclarer = persister.getSubclassPropertyDeclarer( propertyName ); if ( log.isTraceEnabled() ) { log.trace( "handling property dereference [" + persister.getEntityName() + " (" + getClassAlias() + ") -> " + propertyName + " (" + propertyDeclarer + ")]" ); } if ( propertyDeclarer == Queryable.Declarer.SUBCLASS ) { dereferencedBySubclassProperty = true; includeSubclasses = true; } else if ( propertyDeclarer == Queryable.Declarer.SUPERCLASS ) { dereferencedBySuperclassProperty = true; } } catch( QueryException ignore ) { // ignore it; the incoming property could not be found so we // cannot be sure what to do here. At the very least, the // safest is to simply not apply any dereference toggling... } } } public boolean isDereferencedBySuperclassProperty() { return dereferencedBySuperclassProperty; } public boolean isDereferencedBySubclassProperty() { return dereferencedBySubclassProperty; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -