views:

236

answers:

2

so we upgraded to newer Nhibernate and Fluent Nhibernate.

now I' getting this exception: FailedNHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 459

On this hql, which worked fine before the upgrade.

SELECT s.StudId, s.StudLname, s.StudFname, s.StudMi, s.Ssn, s.Sex, s.Dob, et.EnrtypeId, et.Active, et.EnrId, sss.StaffLname, sss.StaffFname, sss.StaffMi,vas.CurrentAge FROM CIS3G.Jcdc.EO.StudentEO s , CIS3G.Jcdc.EO.EnrollmentEO e , CIS3G.Jcdc.EO.EnrollmentTypeEO et , CIS3G.Jcdc.EO.VwStaffStudentStaffEO sss, CIS3G.Jcdc.EO.VwAgeStudentEO vas WHERE ( e.EnrId = et.EnrId ) AND ( s.StudId = vas.StudId ) AND ( s.StudId = e.StudId ) AND ( et.EnrtypeId *= sss.EnrtypeId ) AND ( Isnull ( sss.StudStaffRoleCd , 1044 ) = 1044 ) AND ( s.StudId = 4000 )

Clearly it does nto like the *= syntax, I tried rewritign is as ansi sql outer join and no joy.

Can anyone tell me what ineed to change the sql to so I can get the outer join to work correctly?

Thanks,

Eric-

A: 

You don't need to do explicit joins with NHibernate in order to get the related entities. Instead, map those relations as many-to-one.

For example, your Student class could have a References(x => x.EnrollmentType). With that, you'd only need to select the student (you don't even need HQL if you know the Id; you can use session.Get) and you could just navigate to the other properties.

I recommend you read the NHibernate documentation

Diego Mijelshon
I'm afrid that due to decisions above my pay grade, we ahve to pass HQL or SQL directly teo nhibernate via our libraries, and the map files cant' be changed. The head of Tech wants to make the move to nhibernate gradually, so we're not using it the normal way.Is there a way to do it via the HQL?Thanks,Eric-
Eric Brown - Cal
A: 

We got it working with the ansi sql and calling nhibernate slightly differently.

Is there any way to force antlr to allow t-sql, or to stop antlr parsing all together?

All this sql worked fine before we got the version that added antlr parsing.

In MANY places we are passing T-Sql to NHibernate, becasue we're porting from another app with all the complex SQl already written, and We'd like to avoid having to rewrite & retest all the sql as ansi standard.

Shouldn't the antrl parsing only be applied to HQL only not direct SQL anyway? You reduce the native compatibility for other DBs, like ours.

Thanks,

Eric=

Eric Brown - Cal