Time for another update; it's been a while since the last one. Good progress has been made on the new HQL AST Parser port from Hibernate, and it's now in a state where it's usable, passing the vast majority of the tests within the NHibernate test suite. Of those that are failing (around 8 out of over 1600), we are currently discussing on the developers group whether we will live with these minor breaking changes, or do continued work on the parser to get everything passing.
The current call is to live with the current breaks - the Hibernate AST parser fails in exactly the same way on those tests, so in terms of using Hibernate as our "specification" we are doing exactly the correct thing.
So if anyone fancies playing with the new parser, I think it's about ready. I'm not sure I'd suggest putting it in a live environment right now, but for projects that are still under development it would be great to see it in use to get it "battle hardened". It is expected that we'll get the new parser into the main NH trunk sometime in the next few days - I'll post here once it's up there so you brave souls can give it a spin.
Now, how about the LINQ side of things? That is, after all, the end game here. Well, I've only spent a few hours hacking out some code, but already with the new parser I can turn this:
ISession session = sfi.OpenSession();
NhQueryProvider provider = new NhQueryProvider(session)
Query<Animal> animals = new Query<Animal>(provider);
var x = from a in animals where a.Legs == 8 select a;
into this:
select animal0_.Id as Id0_, animal0_.Description as Descript2_0_, animal0_.BodyWeight as BodyWeight0_, animal0_.Legs as Legs0_, animal0_1_.name_first as name2_1_, animal0_1_.name_initial as name3_1_, animal0_1_.name_last as name4_1_, animal0_1_.NickName as NickName1_, animal0_1_.Birthdate as Birthdate1_, case when animal0_1_.animalId is not null then 1 when animal0_.Id is not null then 0 end as clazz_ from Animal animal0_ left outer join Human animal0_1_ on animal0_.Id=animal0_1_.animalId where animal0_.Legs=8
Now, being fair I've not actually run the SQL, but I suspect it's correct. Also, I've not yet hooked this into the execution pipeline within NH, so I'm not executing the SQL, just generating it. However, that bit should be pretty simple.
Before anyone gets too excited, the code behind this is some of the dirtiest I've ever written. For those of you that know me, you can imagine how bad it must be ;) So it's not getting checked in anywhere, since it would just be an embarrassment. However, I was interested in getting some form of proof of concept up and running, and I'm very pleased at how easy it has been (for this really simple form of query - as I said, don't get *too* excited!).
Next step is to hook this into the execution pipeline to actually get something out of the DB (only a couple of hours work here, I think). Then it's time to step back an look at the big picture to get the design correct.
Carry on watching this space...