Skip to content

Commit af1022a

Browse files
author
Peter Smulovics
committed
Rereading HQL
SVN: trunk@483
1 parent 7186302 commit af1022a

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

src/NHibernate/Hql/ClauseParser.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public class ClauseParser : IParser {
1616
private bool byExpected = false;
1717
private int parenCount = 0;
1818

19-
public virtual void Token(string token, QueryTranslator q) {
19+
public virtual void Token(string token, QueryTranslator q)
20+
{
2021
string lcToken = token.ToLower();
2122

2223
if ( token.Equals(StringHelper.OpenParen ) )
@@ -28,7 +29,8 @@ public virtual void Token(string token, QueryTranslator q) {
2829
parenCount--;
2930
}
3031

31-
if (byExpected && !lcToken.Equals("by")) {
32+
if (byExpected && !lcToken.Equals("by"))
33+
{
3234
throw new QueryException("BY expected after GROUP or ORDER: " + token);
3335
}
3436

@@ -38,7 +40,7 @@ public virtual void Token(string token, QueryTranslator q) {
3840
{
3941
if (lcToken.Equals("select"))
4042
{
41-
selectTokens = new ArrayList();
43+
selectTokens = new ArrayList();
4244
cacheSelectTokens = true;
4345
}
4446
else if (lcToken.Equals("from"))

src/NHibernate/Hql/FilterTranslator.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@
44
using NHibernate.Engine;
55
using System.Runtime.CompilerServices;
66

7-
namespace NHibernate.Hql {
7+
namespace NHibernate.Hql
8+
{
89

9-
public class FilterTranslator : QueryTranslator {
10-
10+
public class FilterTranslator : QueryTranslator
11+
{
1112
public FilterTranslator(Dialect.Dialect d) : base(d)
1213
{
1314
}
1415

15-
/// <summary> Compile a filter. This method may be called multiple
16+
/// <summary>
17+
/// Compile a filter. This method may be called multiple
1618
/// times. Subsequent invocations are no-ops.
1719
/// </summary>
1820
[MethodImpl(MethodImplOptions.Synchronized)]
19-
public void Compile(string collectionRole, ISessionFactoryImplementor factory, string queryString, IDictionary replacements, bool scalar) {
20-
if (!compiled) {
21-
this.factory = factory; // yick!
22-
AddFromCollection("this", collectionRole);
23-
base.Compile(factory, queryString, replacements, scalar);
21+
public void Compile(string collectionRole, ISessionFactoryImplementor factory, string queryString, IDictionary replacements, bool scalar)
22+
{
23+
if (!compiled)
24+
{
25+
this.factory = factory; // yick!
26+
AddFromCollection("this", collectionRole);
27+
base.Compile(factory, queryString, replacements, scalar);
2428
}
2529
}
2630
}

src/NHibernate/Hql/FromParser.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class FromParser : IParser {
2323
private bool expectingAs;
2424
private bool afterJoinType;
2525
private bool afterFetch;
26-
//TODO: H2.0.3 does not have classPersister as a field...
27-
private ILoadable classPersister;
2826
private JoinType joinType = JoinType.None;
2927

3028
private static IDictionary joinTypes = new Hashtable();
@@ -119,11 +117,6 @@ public void Token(string token, QueryTranslator q) {
119117
// _after_ the class name or path expression ie using the
120118
// AS construction
121119

122-
// if (classPersister!=null)
123-
// {
124-
// q.AddFromClass(token, classPersister);
125-
// }
126-
//else if (entityName!=null)
127120
if (entityName!=null)
128121
{
129122
q.SetAliasName(token, entityName);
@@ -136,15 +129,14 @@ public void Token(string token, QueryTranslator q) {
136129
expectingJoin = true;
137130
expectingAs = false;
138131
entityName = null;
139-
classPersister = null;
140-
141132
}
142133
else if (afterIn)
143134
{
144135
// process the "old" HQL style where aliases appear _first
145136
// ie using the IN or IN CLASS constructions
146137

147138
if (alias==null) throw new QueryException("alias not specified for: " + token);
139+
148140
if (joinType!=JoinType.None) throw new QueryException("outer or full join must be followed by path expressions");
149141

150142
if (afterClass)
@@ -180,7 +172,6 @@ public void Token(string token, QueryTranslator q) {
180172
{
181173
// starts with the name of a mapped class (new style)
182174
if (joinType!=JoinType.None) throw new QueryException("outer or full join must be followed by path expression");
183-
classPersister = p;
184175
entityName = q.CreateNameFor( p.MappedClass );
185176
q.AddFromClass( entityName, p );
186177
expectingAs = true;
@@ -197,6 +188,7 @@ public void Token(string token, QueryTranslator q) {
197188
// starts with a path expression (new style)
198189

199190
// force HQL style: from Person p inner join p.cars c
191+
//if (joinType==JoinType.None) throw new QueryException("path expression must be preceded by full, left, right or inner join");
200192

201193
//allow ODMG OQL style: from Person p, p.cars c
202194
if (joinType!=JoinType.None)
@@ -239,9 +231,9 @@ public void Token(string token, QueryTranslator q) {
239231
}
240232
}
241233

242-
public virtual void Start(QueryTranslator q) {
234+
public virtual void Start(QueryTranslator q)
235+
{
243236
entityName = null;
244-
classPersister = null;
245237
alias = null;
246238
afterIn = false;
247239
afterAs = false;
@@ -252,7 +244,8 @@ public virtual void Start(QueryTranslator q) {
252244
joinType = JoinType.None;
253245
}
254246

255-
public virtual void End(QueryTranslator q) {
247+
public virtual void End(QueryTranslator q)
248+
{
256249
}
257250
}
258251
}

0 commit comments

Comments
 (0)