private boolean checkSubclassOrSuperclassPropertyReference(FromReferenceNode lhs, String propertyName) { if ( lhs != null && !( lhs instanceof IndexNode ) ) { final FromElement source = lhs.getFromElement(); if ( source != null ) { source.handlePropertyBeingDereferenced( lhs.getDataType(), propertyName ); } } return false; } }
private String[] getColumns() throws QueryException { if ( columns == null ) { // Use the table fromElement and the property name to get the array of column names. String tableAlias = getLhs().getFromElement().getTableAlias(); columns = getFromElement().toColumns( tableAlias, propertyPath, false ); } return columns; }
@Override protected void validateMapPropertyExpression(AST node) throws SemanticException { try { FromReferenceNode fromReferenceNode = (FromReferenceNode) node; QueryableCollection collectionPersister = fromReferenceNode.getFromElement().getQueryableCollection(); if ( !Map.class.isAssignableFrom( collectionPersister.getCollectionType().getReturnedClass() ) ) { throw new SemanticException( "node did not reference a map" ); } } catch (SemanticException se) { throw se; } catch (Throwable t) { throw new SemanticException( "node did not reference a map" ); } }
private FromElement evaluateFromElementPath(String path, String classAlias) throws SemanticException { ASTFactory factory = fromClause.getASTFactory(); FromReferenceNode pathNode = (FromReferenceNode) PathHelper.parsePath( path, factory ); pathNode.recursiveResolve( // This is the root level node. FromReferenceNode.ROOT_LEVEL, // Generate an explicit from clause at the root. false, classAlias, null ); if ( pathNode.getImpliedJoin() != null ) { return pathNode.getImpliedJoin(); } return pathNode.getFromElement(); }
@Override protected void resolveSelectExpression(AST node) throws SemanticException { // This is called when it's time to fully resolve a path expression. int type = node.getType(); switch ( type ) { case DOT: { DotNode dot = (DotNode) node; dot.resolveSelectExpression(); break; } case ALIAS_REF: { // Notify the FROM element that it is being referenced by the select. FromReferenceNode aliasRefNode = (FromReferenceNode) node; //aliasRefNode.resolve( false, false, aliasRefNode.getText() ); //TODO: is it kosher to do it here? aliasRefNode.resolve( false, false ); //TODO: is it kosher to do it here? FromElement fromElement = aliasRefNode.getFromElement(); if ( fromElement != null ) { fromElement.setIncludeSubclasses( true ); } break; } default: { break; } } }
@Override public Type getDataType() { if ( super.getDataType() == null ) { FromElement fromElement = getLhs().getFromElement(); if ( fromElement == null ) { return null; } // If the lhs is a collection, use CollectionPropertyMapping Type propertyType = fromElement.getPropertyType( propertyPath, propertyPath ); LOG.debugf( "getDataType() : %s -> %s", propertyPath, propertyType ); super.setDataType( propertyType ); } return super.getDataType(); }
private void typeDiscriminator(AST path) throws SemanticException { if ( path == null ) { throw new SemanticException( "type() discriminator reference has no path!" ); } FromReferenceNode pathAsFromReferenceNode = (FromReferenceNode) path; FromElement fromElement = pathAsFromReferenceNode.getFromElement(); TypeDiscriminatorMetadata typeDiscriminatorMetadata = fromElement.getTypeDiscriminatorMetadata(); setDataType( typeDiscriminatorMetadata.getResolutionType() ); setText( typeDiscriminatorMetadata.getSqlFragment() ); setType( SqlTokenTypes.SQL_TOKEN ); }
/** * Resolves the left hand side of the DOT. * * @throws SemanticException */ @Override public void resolveFirstChild() throws SemanticException { FromReferenceNode lhs = (FromReferenceNode) getFirstChild(); SqlNode property = (SqlNode) lhs.getNextSibling(); // Set the attributes of the property reference expression. String propName = property.getText(); propertyName = propName; // If the uresolved property path isn't set yet, just use the property name. if ( propertyPath == null ) { propertyPath = propName; } // Resolve the LHS fully, generate implicit joins. Pass in the property name so that the resolver can // discover foreign key (id) properties. lhs.resolve( true, true, null, this ); setFromElement( lhs.getFromElement() ); // The 'from element' that the property is in. checkSubclassOrSuperclassPropertyReference( lhs, propName ); }
final QueryableCollection collectionPersister = mapReference.getFromElement().getQueryableCollection(); if ( Map.class.isAssignableFrom( collectionPersister.getCollectionType().getReturnedClass() ) ) { sourceFromElement = mapReference.getFromElement(); final CollectionType collectionType = (CollectionType) mapReference.getDataType(); if ( Map.class.isAssignableFrom( collectionType.getReturnedClass() ) ) { sourceFromElement = mapReference.getFromElement();
private void validateLhs(FromReferenceNode lhs) { // make sure the lhs is "assignable"... if ( !lhs.isResolved() ) { throw new UnsupportedOperationException( "cannot validate assignablity of unresolved node" ); } if ( lhs.getDataType().isCollectionType() ) { throw new QueryException( "collections not assignable in update statements" ); } else if ( lhs.getDataType().isComponentType() ) { throw new QueryException( "Components currently not assignable in update statements" ); } else if ( lhs.getDataType().isEntityType() ) { // currently allowed... } // TODO : why aren't these the same? if ( lhs.getImpliedJoin() != null || lhs.getFromElement().isImplied() ) { throw new QueryException( "Implied join paths are not assignable in update statements" ); } } }
private void handleElements(FromReferenceNode collectionNode, String propertyName) { FromElement collectionFromElement = collectionNode.getFromElement(); QueryableCollection queryableCollection = collectionFromElement.getQueryableCollection(); String path = collectionNode.getPath() + "[]." + propertyName; LOG.debugf( "Creating elements for %s", path ); fromElement = collectionFromElement; if ( !collectionFromElement.isCollectionOfValuesOrComponents() ) { getWalker().addQuerySpaces( queryableCollection.getElementPersister().getQuerySpaces() ); } setDataType( queryableCollection.getElementType() ); selectColumns = collectionFromElement.toColumns( fromElement.getTableAlias(), propertyName, inSelect ); }
fromElement = collectionNode.getFromElement();
FromElement lhsFromElement = getLhs().getFromElement(); while ( lhsFromElement != null && ComponentJoin.class.isInstance( lhsFromElement ) ) { lhsFromElement = lhsFromElement.getOrigin(); String lhsTableAlias = getLhs().getFromElement().getTableAlias();
FromElement fromElement = collectionNode.getFromElement(); String elementTable = fromElement.getTableAlias(); FromClause fromClause = fromElement.getFromClause();
FromElement lhsFromElement = getLhs().getFromElement(); while ( lhsFromElement != null && ComponentJoin.class.isInstance( lhsFromElement ) ) { lhsFromElement = lhsFromElement.getOrigin();
dot.getLhs().getFromElement(), dot.getPropertyPath(), alias == null ? null : alias.getText(),
private boolean checkSubclassOrSuperclassPropertyReference(FromReferenceNode lhs, String propertyName) { if ( lhs != null && !( lhs instanceof IndexNode ) ) { final FromElement source = lhs.getFromElement(); if ( source != null ) { source.handlePropertyBeingDereferenced( lhs.getDataType(), propertyName ); } } return false; } }
private boolean checkSubclassOrSuperclassPropertyReference(FromReferenceNode lhs, String propertyName) { if ( lhs != null && !( lhs instanceof IndexNode ) ) { final FromElement source = lhs.getFromElement(); if ( source != null ) { source.handlePropertyBeingDereferenced( lhs.getDataType(), propertyName ); } } return false; } }
private String[] getColumns() throws QueryException { if ( columns == null ) { // Use the table fromElement and the property name to get the array of column names. String tableAlias = getLhs().getFromElement().getTableAlias(); columns = getFromElement().toColumns( tableAlias, propertyPath, false ); } return columns; }
private FromElement evaluateFromElementPath(String path, String classAlias) throws SemanticException { ASTFactory factory = fromClause.getASTFactory(); FromReferenceNode pathNode = ( FromReferenceNode ) PathHelper.parsePath( path, factory ); pathNode.recursiveResolve( FromReferenceNode.ROOT_LEVEL, // This is the root level node. false, // Generate an explicit from clause at the root. classAlias, null ); if (pathNode.getImpliedJoin() != null) return pathNode.getImpliedJoin(); return pathNode.getFromElement(); }