From: Peter S. <sz...@us...> - 2004-04-30 08:58:08
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21335/NHibernate/Hql Modified Files: FromParser.cs HavingParser.cs OrderByParser.cs PathExpressionParser.cs Log Message: Working on HQL Index: FromParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FromParser.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FromParser.cs 30 Apr 2004 08:34:25 -0000 1.7 --- FromParser.cs 30 Apr 2004 08:57:59 -0000 1.8 *************** *** 143,147 **** { // treat it as a classname ! ILoadable p = q.GetPersisterUsingImports(token); if (p==null) throw new QueryException("persister not found: " + token); q.AddFromClass(alias, p); --- 143,147 ---- { // treat it as a classname ! IQueryable p = q.GetPersisterUsingImports(token); if (p==null) throw new QueryException("persister not found: " + token); q.AddFromClass(alias, p); *************** *** 168,172 **** // at the start, in the "new" HQL style or an alias that // appears at the start in the "old HQL stype ! ILoadable p = q.GetPersisterUsingImports(token); if (p!=null) { --- 168,172 ---- // at the start, in the "new" HQL style or an alias that // appears at the start in the "old HQL stype ! IQueryable p = q.GetPersisterUsingImports(token); if (p!=null) { Index: PathExpressionParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/PathExpressionParser.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PathExpressionParser.cs 29 Apr 2004 14:00:52 -0000 1.12 --- PathExpressionParser.cs 30 Apr 2004 08:57:59 -0000 1.13 *************** *** 22,25 **** --- 22,30 ---- //ways in which path expressions can occur + //We should actually rework this class to not implement Parser + //and just process path expressions in the most convenient way. + + //The class is now way to complex! + public const string EntityID = "id"; public const string EntityClass = "class"; *************** *** 39,45 **** protected string[] collectionElementColumns; protected string collectionName; private string collectionRole; private string collectionTable; - private string collectionOwnerName; protected IType collectionElementType; private string componentPath; --- 44,50 ---- protected string[] collectionElementColumns; protected string collectionName; + private string collectionOwnerName; private string collectionRole; private string collectionTable; protected IType collectionElementType; private string componentPath; *************** *** 195,199 **** else { - string name = q.CreateNameFor(memberClass); q.AddType(name, memberClass); --- 200,203 ---- *************** *** 208,223 **** else if (propertyType.IsPersistentCollectionType) { - collectionRole = ((PersistentCollectionType) propertyType).Role; ! CollectionPersister p = q.GetCollectionPersister(collectionRole); ! string[] colNames = p.KeyColumnNames; string name = q.CreateNameForCollection(collectionRole); ! AddJoin( p.QualifiedTableName, name, colNames, q); ! if ( p.HasWhere ) join.AddCondition( p.GetSQLWhereString(name) ); ! DoCollectionProperty(token, p, name); collectionName = name; collectionOwnerName = currentName; ! collectionTable = p.QualifiedTableName; currentName = null; currentProperty = null; --- 212,227 ---- else if (propertyType.IsPersistentCollectionType) { collectionRole = ((PersistentCollectionType) propertyType).Role; ! CollectionPersister collPersister = q.GetCollectionPersister(collectionRole); ! string[] colNames = collPersister.KeyColumnNames; string name = q.CreateNameForCollection(collectionRole); ! string tableName = collPersister.QualifiedTableName; ! AddJoin( tableName, name, colNames, q); ! if ( collPersister.HasWhere ) join.AddCondition( collPersister.GetSQLWhereString(name) ); ! DoCollectionProperty(token, collPersister, name); collectionName = name; collectionOwnerName = currentName; ! collectionTable = collPersister.QualifiedTableName; currentName = null; currentProperty = null; *************** *** 228,234 **** if (token != null) throw new QueryException("dereferenced: " + currentProperty); } - } - } } --- 232,236 ---- *************** *** 321,325 **** else { - if (!continuation) { --- 323,326 ---- *************** *** 333,337 **** if (collectionRole != null) { - //special case; expecting: [index] CollectionPersister memberPersister = q.GetCollectionPersister(collectionRole); --- 334,337 ---- *************** *** 346,350 **** if ( memberPersister.IsOneToMany ) { ! ILoadable persister = q.GetPersister( ( (EntityType) memberPersister.ElementType ).PersistentClass ); ojf.AddJoins( persister.FromJoinFragment(collectionName, true, false), --- 346,350 ---- if ( memberPersister.IsOneToMany ) { ! IQueryable persister = q.GetPersister( ( (EntityType) memberPersister.ElementType ).PersistentClass ); ojf.AddJoins( persister.FromJoinFragment(collectionName, true, false), *************** *** 360,364 **** string[] eltCols = memberPersister.ElementColumnNames; ! //if ( eltCols.length!=1 ) throw new QueryException("composite-id collection element []"); CollectionElement elem = new CollectionElement(); --- 360,364 ---- string[] eltCols = memberPersister.ElementColumnNames; ! //if ( eltCols.Length!=1 ) throw new QueryException("composite-id collection element []"); CollectionElement elem = new CollectionElement(); *************** *** 472,476 **** public string GetCollectionSubquery() { ! return new StringBuilder("SELECT ") .Append(String.Join(", ", collectionElementColumns)) --- 472,476 ---- public string GetCollectionSubquery() { ! //TODO: refactor to .sql package return new StringBuilder("SELECT ") .Append(String.Join(", ", collectionElementColumns)) *************** *** 487,491 **** public bool IsCollectionValued { ! get { return collectionElementColumns!=null; } } --- 487,494 ---- public bool IsCollectionValued { ! get ! { ! return collectionElementColumns!=null; ! } } *************** *** 521,525 **** { q.AddCollection(collectionName, collectionRole); ! ILoadable p = q.GetPersister(clazz); elementName = q.CreateNameFor(clazz); string[] keyColumnNames = p.IdentifierColumnNames; --- 524,528 ---- { q.AddCollection(collectionName, collectionRole); ! IQueryable p = q.GetPersister(clazz); elementName = q.CreateNameFor(clazz); string[] keyColumnNames = p.IdentifierColumnNames; Index: OrderByParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/OrderByParser.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OrderByParser.cs 14 Apr 2004 11:35:53 -0000 1.4 --- OrderByParser.cs 30 Apr 2004 08:57:59 -0000 1.5 *************** *** 22,26 **** public void Token(string token, QueryTranslator q) { - if (q.IsName(StringHelper.Root(token))) { --- 22,25 ---- Index: HavingParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/HavingParser.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HavingParser.cs 15 Apr 2004 11:36:35 -0000 1.5 --- HavingParser.cs 30 Apr 2004 08:57:59 -0000 1.6 *************** *** 1,15 **** using System; ! namespace NHibernate.Hql { /// <summary> /// Parses the having clause of a hibernate query and translates it to an /// SQL having clause. /// </summary> ! public class HavingParser : WhereParser { public HavingParser(Dialect.Dialect d) : base(d) { } ! protected override void AppendToken(QueryTranslator q, string token) { q.AppendHavingToken(token); } --- 1,18 ---- using System; ! namespace NHibernate.Hql ! { /// <summary> /// Parses the having clause of a hibernate query and translates it to an /// SQL having clause. /// </summary> ! public class HavingParser : WhereParser ! { public HavingParser(Dialect.Dialect d) : base(d) { } ! protected override void AppendToken(QueryTranslator q, string token) ! { q.AppendHavingToken(token); } |