Author: steve.ebersole(a)jboss.com
Date: 2009-04-13 12:42:44 -0400 (Mon, 13 Apr 2009)
New Revision: 16307
Added:
core/branches/SQL_GEN_REDESIGN/src/main/antlr/v3/
core/branches/SQL_GEN_REDESIGN/src/main/antlr/v3/order/
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/render/
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/render/TableAliasBuilder.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ASTFactoryImpl.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/AliasRef.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Column.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ExpectedTypeAware.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HqlResolver.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Name.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/PersisterTableProcesser.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/RowValueConstructorList.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Table.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Typed.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/load/
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/load/LoadPlan.java
Log:
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/render/TableAliasBuilder.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/render/TableAliasBuilder.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/render/TableAliasBuilder.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.render;
+
+import org.hibernate.persister.entity.Queryable;
+import org.hibernate.persister.collection.QueryableCollection;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public interface TableAliasBuilder {
+
+ public static class AliasRoot {
+ private final String base;
+
+ public AliasRoot(String base) {
+ this.base = base;
+ }
+
+ public String generate(int suffix) {
+ return base + Integer.toString( suffix ) + '_';
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+ AliasRoot aliasRoot = ( AliasRoot ) o;
+ return base.equals( aliasRoot.base );
+ }
+
+ public int hashCode() {
+ return base.hashCode();
+ }
+ }
+
+ public AliasRoot getSqlAliasRoot(Queryable persister, String alias);
+
+ public AliasRoot getSqlAliasRoot(QueryableCollection persister, String alias);
+
+ public AliasRoot getSimpleSqlAliasRoot(QueryableCollection persister);
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ASTFactoryImpl.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ASTFactoryImpl.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ASTFactoryImpl.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.hibernate.sql.ast.common.NodeFactory;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class ASTFactoryImpl extends NodeFactory implements HqlResolveTokenTypes {
+ public Class getASTNodeType(int tokenType) {
+ switch ( tokenType ) {
+ case TABLE :
+ return Table.class;
+ case COLUMN :
+ return Column.class;
+ case ALIAS_REF :
+ return AliasRef.class;
+ case NAME :
+ return Name.class;
+ case ROW_VALUE_CONSTRUCTOR_LIST :
+ return RowValueConstructorList.class;
+ default:
+ return determineDefaultNodeClass();
+ }
+ }
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/AliasRef.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/AliasRef.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/AliasRef.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.hibernate.sql.ast.common.Node;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class AliasRef extends Node {
+ public AliasRef() {
+ }
+
+ public AliasRef(String alias) {
+ setType( HqlResolveTokenTypes.ALIAS_REF );
+ setText( alias );
+ }
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Column.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Column.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Column.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.hibernate.sql.ast.common.Node;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class Column extends Node {
+ private String selectAlias;
+
+ public Column() {
+ }
+
+ public Column(String tableAlias, String columnName) {
+ super();
+ setType( HqlResolveTokenTypes.COLUMN );
+ setText( '{' + tableAlias + '.' + columnName + '}' );
+ addChild( new AliasRef( tableAlias ) );
+ addChild( new Name( columnName ) );
+ }
+
+ public Column injectSelectAlias(String selectAlias) {
+ this.selectAlias = selectAlias;
+ return this;
+ }
+
+ public String getSelectAlias() {
+ return selectAlias;
+ }
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ExpectedTypeAware.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ExpectedTypeAware.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/ExpectedTypeAware.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.hibernate.type.Type;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public interface ExpectedTypeAware extends Typed {
+ public void setExpectedType(Type expectedType);
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HqlResolver.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HqlResolver.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/HqlResolver.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,303 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import java.util.HashMap;
+
+import antlr.ASTFactory;
+import antlr.RecognitionException;
+import antlr.collections.AST;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.MappingException;
+import org.hibernate.QueryException;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.persister.entity.Queryable;
+import org.hibernate.sql.ast.alias.DefaultTableAliasGenerator;
+import org.hibernate.sql.ast.util.ASTPrinter;
+import org.hibernate.sql.ast.util.ErrorHandlerDelegateImpl;
+import org.hibernate.sql.ast.util.ErrorHandlerDelegate;
+import org.hibernate.sql.ast.alias.TableAliasGenerator;
+import
org.hibernate.sql.ast.phase.hql.resolve.expression.ExpressionResolutionStrategyStack;
+import
org.hibernate.sql.ast.phase.hql.resolve.expression.DefaultExpressionResolutionStrategy;
+import
org.hibernate.sql.ast.phase.hql.resolve.expression.SelectClauseExpressionResolutionStrategy;
+import
org.hibernate.sql.ast.phase.hql.resolve.expression.FunctionArgumentExpressionResolutionStrategy;
+import org.hibernate.type.AssociationType;
+import org.hibernate.util.StringHelper;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class HqlResolver extends GeneratedHqlResolver {
+ private static final Logger log = LoggerFactory.getLogger( HqlResolver.class );
+
+ private final SessionFactoryImplementor sessionFactory;
+ private final ErrorHandlerDelegate parseErrorHandler = new ErrorHandlerDelegateImpl();
+ private final ASTPrinter printer = new ASTPrinter( HqlResolveTokenTypes.class );
+
+ private final TableAliasGenerator tableAliasGenerator;
+ private final PersisterTableProcesser persisterTableProcesser;
+
+ private ExpressionResolutionStrategyStack expressionResolverStack = new
ExpressionResolutionStrategyStack();
+
+ private AST collectionFilterCondition;
+
+ public HqlResolver(SessionFactoryImplementor sessionFactory) {
+ super();
+ super.setASTFactory( new ASTFactoryImpl() );
+ this.sessionFactory = sessionFactory;
+ // todo : make this configurable
+ this.tableAliasGenerator = new DefaultTableAliasGenerator( sessionFactory.getDialect()
);
+ this.persisterTableProcesser = new PersisterTableProcesser( getASTFactory() );
+ expressionResolverStack.push( new DefaultExpressionResolutionStrategy( this ) );
+ }
+
+ public ASTPrinter getPrinter() {
+ return printer;
+ }
+
+
+ // overrides of Antlr infastructure methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public void reportError(RecognitionException e) {
+ getParseErrorHandler().reportError( e );
+ }
+
+ public void reportError(String s) {
+ getParseErrorHandler().reportError( s );
+ }
+
+ public void reportWarning(String s) {
+ getParseErrorHandler().reportWarning( s );
+ }
+
+ public ErrorHandlerDelegate getParseErrorHandler() {
+ return parseErrorHandler;
+ }
+
+ static public void panic() {
+ //overriden to avoid System.exit
+ throw new QueryException( "Parser: panic" );
+ }
+
+ public void setASTFactory(ASTFactory astFactory) {
+ throw new UnsupportedOperationException( "not allowed!" );
+ }
+
+
+ // handle trace logging
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public void traceIn(String ruleName, AST tree) {
+ if ( inputState.guessing > 0 ) {
+ return;
+ }
+ String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "->
";
+ String traceText = ruleName + " (" + buildTraceNodeName(tree) +
")";
+ trace( prefix + traceText );
+ }
+
+ private String buildTraceNodeName(AST tree) {
+ return tree == null
+ ? "???"
+ : tree.getText() + " [" + printer.getTokenTypeName( tree.getType() ) +
"]";
+ }
+
+ public void traceOut(String ruleName, AST tree) {
+ if ( inputState.guessing > 0 ) {
+ return;
+ }
+ String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth *
2) ) + " ";
+ trace( prefix + ruleName );
+ }
+
+ private void trace(String msg) {
+ System.out.println( msg );
+// log.trace( msg );
+ }
+
+
+ // semantic action overrides
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private HashMap aliasToTableSpaceMap = new HashMap();
+
+ public Table.TableSpace resolveTableSpaceByAlias(String alias) {
+ return ( Table.TableSpace ) aliasToTableSpaceMap.get( alias );
+ }
+
+ protected AST resolveEntityPersister(AST entityName, AST alias, AST filter) {
+ final Queryable persister = ( Queryable ) sessionFactory.getEntityPersister(
entityName.getText() );
+ final String aliasText = alias.getText();
+
+ Table.EntityTableSpace tableSpace = new Table.EntityTableSpace( persister, aliasText
);
+ aliasToTableSpaceMap.put( aliasText, tableSpace );
+
+ TableAliasGenerator.TableAliasRoot aliasRoot =
tableAliasGenerator.generateSqlAliasRoot( persister, aliasText );
+
+ Table table = persisterTableProcesser.buildTables(
+ persister,
+ aliasRoot,
+ tableSpace
+ );
+
+ if ( filter != null ) {
+ String filteredCollectionRole = filter.getText();
+ QueryableCollection filteredCollectionPersister =
+ ( QueryableCollection ) sessionFactory.getCollectionPersister(
filteredCollectionRole );
+ collectionFilterCondition = persisterTableProcesser.handleCollectionFilterConditions(
+ table,
+ aliasRoot,
+ filteredCollectionPersister
+ );
+ }
+
+ return table;
+ }
+
+ protected void postProcessQuery(AST query) {
+ if ( collectionFilterCondition != null ) {
+ AST selectClause = query.getFirstChild();
+ AST fromClause = selectClause.getNextSibling();
+ AST whereClause = fromClause.getNextSibling();
+ if ( whereClause == null ) {
+ // there was no where-clause, group-by-clause or having-clause...
+ whereClause = astFactory.create( WHERE, "where" );
+ fromClause.setNextSibling( whereClause );
+ }
+ else if ( whereClause.getType() == GROUP_BY ) {
+ // there was no where-clause, but was a group-by-clause
+ AST groupByClause = whereClause;
+ whereClause = astFactory.create( WHERE, "where" );
+ whereClause.setNextSibling( groupByClause );
+ fromClause.setNextSibling( whereClause );
+ }
+ assert whereClause.getType() == WHERE : "mis-structured AST";
+ log.trace( printer.showAsString( collectionFilterCondition, "collection-filter
key condition" ) );
+ appendSearchCondition( collectionFilterCondition, whereClause );
+ collectionFilterCondition = null;
+ }
+ }
+
+ protected AST resolveCollectionPersister(AST collectionRole, AST alias) {
+ return super.resolveCollectionPersister( collectionRole, alias );
+ }
+
+ protected void applyPropertyJoin(AST lhs, AST rhs, AST propertyName, AST joinType,
AST with) {
+ final AST correlation = generateAssociationJoinCondition( lhs, rhs, propertyName );
+ AST on = astFactory.create( ON, "on" );
+ if ( with == null ) {
+ on.addChild( correlation );
+ }
+ else {
+ AST and = astFactory.create( AND, "and" );
+ and.addChild( correlation );
+ and.addChild( with );
+ on.addChild( and );
+ }
+
+ AST join = astFactory.create( JOIN, "join" );
+ join.addChild( joinType );
+ join.addChild( rhs );
+ join.addChild( on );
+
+ lhs.addChild( join );
+ }
+
+ private AST generateAssociationJoinCondition(AST lhs, AST rhs, AST propertyName) {
+ final String propertyNameText = propertyName.getText();
+ Table lhsTable = ( Table ) lhs;
+ Table.TableSpace lhsTableSpace = lhsTable.getTableSpace();
+ String lhsTableAlias = lhsTableSpace.getContainingTable( propertyNameText
).getAliasText();
+ String[] lhsJoinColumns = lhsTableSpace.getPropertyColumnNames( propertyNameText );
+
+ AssociationType propertyType = ( AssociationType ) lhsTableSpace.getPropertyType(
propertyNameText );
+ String rhsPropertyName = propertyType.getRHSUniqueKeyPropertyName();
+ Table.TableSpace rhsTableSpace = ( ( Table ) rhs ).getTableSpace();
+ String rhsTableAlias;
+ String[] rhsJoinColumns;
+ if ( rhsPropertyName == null ) {
+ // reference to RHS PK
+ rhsTableAlias = rhsTableSpace.getJoinIntoTable().getAliasText();
+ rhsJoinColumns = rhsTableSpace.getJoinIntoColumns();
+ }
+ else {
+ // reference to RHS property-ref
+ Table rhsTable = rhsTableSpace.getContainingTable( rhsPropertyName );
+ rhsTableAlias = rhsTable.getAliasText();
+ rhsJoinColumns = rhsTableSpace.getPropertyColumnNames( rhsPropertyName );
+ }
+
+ if ( lhsJoinColumns.length != rhsJoinColumns.length ) {
+ throw new MappingException( "Association had unequal number of columns : " +
propertyType.getName() );
+ }
+
+ return persisterTableProcesser.generateJoinCorrelation( lhsTableAlias, lhsJoinColumns,
rhsTableAlias, rhsJoinColumns );
+ }
+
+ protected AST generateIndexValueCondition(AST lhs, AST rhs, AST propertyName, AST
selector) {
+ return super.generateIndexValueCondition( lhs, rhs, propertyName, selector );
+ }
+
+ protected void startSelectClause() {
+ expressionResolverStack.push( new SelectClauseExpressionResolutionStrategy( this ) );
+ }
+
+ protected void finishSelectClause() {
+ expressionResolverStack.pop();
+ }
+
+ protected void startFunction() {
+ expressionResolverStack.push( new FunctionArgumentExpressionResolutionStrategy( this )
);
+ }
+
+ protected void finishFunction() {
+ expressionResolverStack.pop();
+ }
+
+ protected void appendSearchCondition(AST condition, AST container) {
+ if ( container.getFirstChild() == null ) {
+ container.setFirstChild( condition );
+ }
+ else {
+ AST and = getASTFactory().create( AND, "and" );
+ and.setFirstChild( container.getFirstChild() );
+ and.addChild( condition );
+ container.setFirstChild( and );
+ }
+ }
+
+ protected AST resolvePropertyReference(AST persisterAlias, AST propertyName) {
+ final String aliasText = persisterAlias.getText();
+ final String propertyNameText = propertyName.getText();
+
+ return expressionResolverStack.getCurrent().resolvePropertyReference( aliasText,
propertyNameText );
+ }
+
+ protected AST resolveAliasReference(AST aliasReference) {
+ return expressionResolverStack.getCurrent().resolveAliasReference(
aliasReference.getText() );
+ }
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Name.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Name.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Name.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.hibernate.sql.ast.common.Node;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class Name extends Node {
+ public Name() {
+ }
+
+ public Name(String name) {
+ setType( HqlResolveTokenTypes.NAME );
+ setText( name );
+ }
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/PersisterTableProcesser.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/PersisterTableProcesser.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/PersisterTableProcesser.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,226 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import antlr.ASTFactory;
+import antlr.collections.AST;
+
+import org.hibernate.persister.entity.Queryable;
+import org.hibernate.persister.entity.Joinable;
+import org.hibernate.persister.MappedTableMetadata;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.sql.ast.alias.TableAliasGenerator;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class PersisterTableProcesser implements HqlResolveTokenTypes {
+ private final ASTFactory astFactory;
+
+ public PersisterTableProcesser(ASTFactory astFactory) {
+ this.astFactory = astFactory;
+ }
+
+ public Table buildTables(Queryable persister, TableAliasGenerator.TableAliasRoot
aliasRoot, Table.EntityTableSpace tableSpace) {
+ MappedTableMetadata tableMetadata = persister.getMappedTableMetadata();
+
+ final String drivingTableName = tableMetadata.getDrivingTableName();
+ final String[] drivingTableJoinColumns = tableMetadata.getIdentifierColumnNames();
+ final String drivingTableAlias = aliasRoot.generate( 0 );
+ final Table drivingTable = generateTableReference( drivingTableName, drivingTableAlias
);
+ tableSpace.registerTable( drivingTable );
+
+ int suffix = 0;
+
+ MappedTableMetadata.JoinedTable[] tables = tableMetadata.getJoinedTables();
+ for ( int i = 0; i < tables.length; i++ ) {
+ final String joinTableAlias = aliasRoot.generate( ++suffix );
+ final Table table = generateTableReference( tables[i].getName(), joinTableAlias );
+ tableSpace.registerTable( table );
+
+ final AST join = astFactory.create( JOIN, "join" );
+ drivingTable.addChild( join );
+ join.setFirstChild( tables[i].useInnerJoin() ? astFactory.create( INNER,
"inner" ) : astFactory.create( LEFT, "left outer" ) );
+ join.addChild( table );
+
+ final AST on = astFactory.create( ON, "on" );
+ join.addChild( on );
+ on.setFirstChild( generateJoinCorrelation( drivingTableAlias, drivingTableJoinColumns,
joinTableAlias, tables[i].getKeyColumns() ) );
+ }
+
+ return drivingTable;
+ }
+
+ public Table buildTables(
+ QueryableCollection collectionPersister,
+ TableAliasGenerator.TableAliasRoot aliasRoot,
+ Table.CollectionTableSpace tableSpace) {
+ if ( collectionPersister.isOneToMany() ) {
+ Table table = buildTables(
+ ( Queryable ) collectionPersister.getElementPersister(),
+ aliasRoot,
+ tableSpace.getEntityElementTableSpace()
+ );
+ tableSpace.setCollectionTable( table );
+ return table;
+ }
+ else {
+ Table associationTable = generateTableReference(
+ collectionPersister.getTableName(),
+ aliasRoot.generateCollectionTableAlias()
+ );
+ tableSpace.setCollectionTable( associationTable );
+
+ if ( collectionPersister.isManyToMany() ) {
+ Queryable elementPersister = ( Queryable )
collectionPersister.getElementPersister();
+ Table drivingTable = buildTables(
+ elementPersister,
+ aliasRoot,
+ tableSpace.getEntityElementTableSpace()
+ );
+
+ AST join = astFactory.create( JOIN, "join" );
+ associationTable.addChild( join );
+ join.addChild( astFactory.create( LEFT, "left outer" ) );
+ join.addChild( drivingTable );
+
+ String[] entityFkColumnNames = collectionPersister.getElementColumnNames();
+ String[] entityPkColumnNames = elementPersister.getKeyColumnNames();
+
+ AST on = astFactory.create( ON, "on" );
+ join.addChild( on );
+ on.setFirstChild(
+ generateJoinCorrelation(
+ associationTable.getAliasText(),
+ entityFkColumnNames,
+ drivingTable.getAliasText(),
+ entityPkColumnNames
+ )
+ );
+ }
+ return associationTable;
+ }
+ }
+
+ public AST handleCollectionFilterConditions(
+ Table drivingEntityTable,
+ TableAliasGenerator.TableAliasRoot aliasRoot,
+ QueryableCollection filteredCollectionPersister) {
+ Table collectionKeyTable = drivingEntityTable;
+
+ if ( !filteredCollectionPersister.isOneToMany() ) {
+ // need to deal with the collection table, which is where the collection-key would
be...
+ Table associationTable = generateTableReference(
+ filteredCollectionPersister.getTableName(),
+ aliasRoot.generateCollectionTableAlias()
+ );
+
+ String[] entityFkColumnNames = filteredCollectionPersister.getElementColumnNames();
+ String[] entityPkColumnNames = ( ( Joinable )
filteredCollectionPersister.getElementPersister() ).getKeyColumnNames();
+
+ AST join = astFactory.create( JOIN, "join" );
+ drivingEntityTable.addChild( join );
+ join.addChild( astFactory.create( LEFT, "left outer" ) );
+ join.addChild( associationTable );
+
+ AST on = astFactory.create( ON, "on" );
+ join.addChild( on );
+ on.setFirstChild(
+ generateJoinCorrelation(
+ drivingEntityTable.getAliasText(),
+ entityPkColumnNames,
+ associationTable.getAliasText(),
+ entityFkColumnNames
+ )
+ );
+
+ collectionKeyTable = associationTable;
+ }
+
+ return generateCollectionFilterRestriction(
+ collectionKeyTable.getAliasText(),
+ filteredCollectionPersister.getKeyColumnNames()
+ );
+ }
+
+ private Table generateTableReference(String tableName, String alias) {
+ Table tableReference = ( Table ) astFactory.create( TABLE, "table" );
+ tableReference.addChild( astFactory.create( NAME, tableName ) );
+ tableReference.addChild( astFactory.create( ALIAS, alias ) );
+ return tableReference;
+ }
+
+ public AST generateJoinCorrelation(
+ String lhsAlias,
+ String[] lhsColumns,
+ String rhsAlias,
+ String[] rhsColumns) {
+ AST correlation = generateJoinCorrelation( lhsAlias, lhsColumns[0], rhsAlias,
rhsColumns[0] );
+ if ( lhsColumns.length > 1 ) {
+ for ( int i = 1; i < lhsColumns.length; i++ ) {
+ AST previous = correlation;
+ correlation = astFactory.create( AND, "and" );
+ correlation.setFirstChild( previous );
+ correlation.addChild( generateJoinCorrelation( lhsAlias, lhsColumns[i], rhsAlias,
rhsColumns[i] ) );
+ }
+ }
+ return correlation;
+ }
+
+ public AST generateJoinCorrelation(String lhsAlias, String lhsColumn, String rhsAlias,
String rhsColumn) {
+ AST lhs = astFactory.create( COLUMN, "column" );
+ lhs.addChild( astFactory.create( ALIAS_REF, lhsAlias ) );
+ lhs.addChild( astFactory.create( NAME, lhsColumn ) );
+
+ AST rhs = astFactory.create( COLUMN, "column" );
+ rhs.addChild( astFactory.create( ALIAS_REF, rhsAlias ) );
+ rhs.addChild( astFactory.create( NAME, rhsColumn ) );
+
+ AST correlation = astFactory.create( EQUALS_OP, "=" );
+ correlation.addChild( lhs );
+ correlation.addChild( rhs );
+
+ return correlation;
+ }
+
+ private AST generateCollectionFilterRestriction(String alias, String[] keyColumns) {
+ // todo : for now we restrict this to single-column FKs
+ // Looks like this is true of old code as well...
+
+ AST column = astFactory.create( COLUMN, "column" );
+ column.addChild( astFactory.create( ALIAS_REF, alias ) );
+ column.addChild( astFactory.create( NAME, keyColumns[0] ) );
+
+ AST param = astFactory.create( NAMED_PARAM, "collection-filter-key" ); //
todo : put this in a well known place
+
+ AST correlation = astFactory.create( EQUALS_OP, "=" );
+ correlation.addChild( column );
+ correlation.addChild( param );
+
+ return correlation;
+ }
+
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/RowValueConstructorList.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/RowValueConstructorList.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/RowValueConstructorList.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,75 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.sql.ast.common.Node;
+import org.hibernate.type.Type;
+import org.hibernate.type.ComponentType;
+
+import antlr.collections.AST;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class RowValueConstructorList extends Node implements ExpectedTypeAware {
+ private static final Logger log = LoggerFactory.getLogger( RowValueConstructorList.class
);
+
+ private Type hibernateType;
+
+ public RowValueConstructorList() {
+ setType( HqlResolveTokenTypes.ROW_VALUE_CONSTRUCTOR_LIST );
+ setText( "row-value-ctor-list" );
+ }
+
+ public void setExpectedType(Type expectedType) {
+ if ( hibernateType != null ) {
+ log.info( "Over-setting expected type [{} -> {}]",
hibernateType.getName(), expectedType.getName() );
+ }
+ hibernateType = expectedType;
+ if ( expectedType.isComponentType() ) {
+ final ComponentType componentType = ( ComponentType ) expectedType;
+ final Type[] subtypes = componentType.getSubtypes();
+ final int length = subtypes.length;
+ if ( length == getNumberOfChildren() ) {
+ AST child = getFirstChild();
+ for ( int i = 0, max = subtypes.length; i < max; i++ ) {
+ if ( child instanceof ExpectedTypeAware ) {
+ log.debug( "propogating expected type info for component sub-property
[{}]", componentType.getPropertyNames()[i] );
+ ( ( ExpectedTypeAware ) child ).setExpectedType( subtypes[i] );
+ }
+ child = child.getNextSibling();
+ }
+ }
+ }
+ }
+
+ public Type getHibernateType() {
+ return hibernateType;
+ }
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Table.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Table.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Table.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,237 @@
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.sql.ast.common.Node;
+import org.hibernate.sql.ast.alias.ImplicitAliasGenerator;
+import org.hibernate.sql.ast.util.DisplayableNode;
+import org.hibernate.persister.entity.Queryable;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.util.StringHelper;
+import org.hibernate.type.Type;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class Table extends Node implements DisplayableNode {
+ private TableSpace tableSpace;
+
+ public Table() {
+ setType( HqlResolveTokenTypes.TABLE );
+ setText( "table" );
+ }
+
+ public TableSpace getTableSpace() {
+ return tableSpace;
+ }
+
+ public Node getTableName() {
+ return ( Node ) getFirstChild();
+ }
+
+ public String getTableNameText() {
+ return getTableName().getText();
+ }
+
+ public Node getAlias() {
+ return ( Node ) getFirstChild().getNextSibling();
+ }
+
+ public String getAliasText() {
+ return getAlias().getText();
+ }
+
+ public String getText() {
+ return getTableNameText() + " (" + getAliasText() + ")";
+ }
+
+ public String getDisplayText() {
+ return "[source-alias=" + tableSpace.getSourceAlias() + "]";
+ }
+
+ public static interface TableSpace {
+ /**
+ * Used as a unique identification since each table space originates from a single
source alias (persister reference).
+ *
+ * @return The source alias.
+ */
+ public String getSourceAlias();
+
+ /**
+ * Get the table reference that should act as the RHS for this table space whenever we
join to into it.
+ *
+ * @return The RHS table for joining into this table space structure.
+ */
+ public Table getJoinIntoTable();
+
+ public String[] getJoinIntoColumns();
+
+ /**
+ * Get the table reference that contains the columns to which the given property is
mapped.
+ *
+ * @param propertyName The name of the property for which to locate the containing
table.
+ *
+ * @return The containing table.
+ */
+ public Table getContainingTable(String propertyName);
+
+ public Type getPropertyType(String propertyName);
+
+ public String[] getPropertyColumnNames(String propertyName);
+
+ public List buildIdentifierColumnReferences();
+
+ public List buildCompleteColumnReferences();
+ }
+
+ public static abstract class AbstractTableSpace implements Table.TableSpace {
+ private final String sourceAlias;
+ private final String sqlAliasBaseRoot;
+
+ private AbstractTableSpace(String sourceAlias, String persisterName) {
+ this.sourceAlias = sourceAlias;
+ this.sqlAliasBaseRoot = ImplicitAliasGenerator.isImplicitAlias( sourceAlias ) ?
persisterName : sourceAlias;
+ }
+
+ public String getSourceAlias() {
+ return sourceAlias;
+ }
+
+ public String getSqlAliasBaseRoot() {
+ return sqlAliasBaseRoot;
+ }
+ }
+
+ public static class EntityTableSpace extends AbstractTableSpace {
+ private final Queryable entityPersister;
+ private final ArrayList tables;
+
+ public EntityTableSpace(Queryable entityPersister, String sourecAlias) {
+ super( sourecAlias, StringHelper.unqualifyEntityName( entityPersister.getEntityName()
) );
+ this.entityPersister = entityPersister;
+ int numberOfTables = entityPersister.getMappedTableMetadata().getJoinedTables().length
+ 1;
+ int listSize = numberOfTables + (int) ( numberOfTables * .75 ) + 1;
+ this.tables = new ArrayList( listSize );
+ }
+
+ public Queryable getEntityPersister() {
+ return entityPersister;
+ }
+
+ public void registerTable(Table table) {
+ table.tableSpace = this;
+ tables.add( table );
+ }
+
+ public Table getDrivingTable() {
+ return ( Table ) tables.get( 0 );
+ }
+
+ public Table getJoinIntoTable() {
+ return getDrivingTable();
+ }
+
+ public String[] getJoinIntoColumns() {
+ return entityPersister.getIdentifierColumnNames();
+ }
+
+ public Table getContainingTable(String propertyName) {
+ return ( Table ) tables.get( entityPersister.getSubclassPropertyTableNumber(
propertyName ) );
+ }
+
+ public Type getPropertyType(String propertyName) {
+ return entityPersister.getPropertyType( propertyName );
+ }
+
+ public String[] getPropertyColumnNames(String propertyName) {
+ int index = entityPersister.getEntityMetamodel().getPropertyIndex( propertyName );
+ return entityPersister.getPropertyColumnNames( index );
+ }
+
+ public List buildIdentifierColumnReferences() {
+ String[] identifierColumnsNames = entityPersister.getIdentifierColumnNames();
+ ArrayList columnsReferences = new ArrayList( collectionSizeWithoutRehashing(
identifierColumnsNames.length ) );
+ for ( int i = 0; i < identifierColumnsNames.length; i++ ) {
+ columnsReferences.add( new Column( getDrivingTable().getAliasText(),
identifierColumnsNames[i] ) );
+ }
+ return columnsReferences;
+ }
+
+ public List buildCompleteColumnReferences() {
+ // todo : implement
+ return null;
+ }
+ }
+
+ private static int collectionSizeWithoutRehashing(int elements) {
+ // usually collection load factors are .75
+ return collectionSizeWithoutRehashing( elements, .75 );
+ }
+
+ private static int collectionSizeWithoutRehashing(int elements, double factor) {
+ return elements + ( (int) ( elements * factor ) + 1 );
+ }
+
+ public static class CollectionTableSpace extends AbstractTableSpace {
+ private final QueryableCollection persister;
+ private final boolean areElementsEntities;
+
+ private Table collectionTable;
+ private EntityTableSpace entityElementTableSpace;
+
+ public CollectionTableSpace(QueryableCollection persister, String sourceAlias) {
+ super( sourceAlias, StringHelper.unqualify( persister.getRole() ) );
+ this.persister = persister;
+ this.areElementsEntities = persister.getElementType().isEntityType();
+ if ( areElementsEntities ) {
+ entityElementTableSpace = new EntityTableSpace( ( Queryable )
persister.getElementPersister(), sourceAlias );
+ }
+ }
+
+ public QueryableCollection getPersister() {
+ return persister;
+ }
+
+ public void setCollectionTable(Table collectionTable) {
+ this.collectionTable = collectionTable;
+ }
+
+ public EntityTableSpace getEntityElementTableSpace() {
+ return entityElementTableSpace;
+ }
+
+ public Table getJoinIntoTable() {
+ return collectionTable;
+ }
+
+ public String[] getJoinIntoColumns() {
+ return persister.getKeyColumnNames();
+ }
+
+ public Table getContainingTable(String propertyName) {
+ // todo : are we needing to handle "collection properties" (SIZE, etc) here
still?
+ return getEntityElementTableSpace().getContainingTable( propertyName );
+ }
+
+ public Type getPropertyType(String propertyName) {
+ return getEntityElementTableSpace().getPropertyType( propertyName );
+ }
+
+ public String[] getPropertyColumnNames(String propertyName) {
+ return getEntityElementTableSpace().getPropertyColumnNames( propertyName );
+ }
+
+ public List buildIdentifierColumnReferences() {
+ // todo : implement
+ return null;
+ }
+
+ public List buildCompleteColumnReferences() {
+ // todo : implement
+ return null;
+ }
+ }
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Typed.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Typed.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/Typed.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import org.hibernate.type.Type;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public interface Typed {
+ public Type getHibernateType();
+}
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/load/LoadPlan.java
===================================================================
---
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/load/LoadPlan.java
(rev 0)
+++
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/resolve/load/LoadPlan.java 2009-04-13
16:42:44 UTC (rev 16307)
@@ -0,0 +1,38 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ast.phase.hql.resolve.load;
+
+import org.hibernate.type.Type;
+
+/**
+ * I want this to be an encapsulation of the information needed by Loader. Stuff like
the persisters, the aliases, etc...
+ *
+ * @author Steve Ebersole
+ */
+public class LoadPlan {
+ // todo : distinguish (interfaces/impls?) between dynamic-instantiation, scalar, and
entity load plans
+
+ private Type[] queryReturnTypes;
+
+}