Archive for the ‘NHibernate.Remote’ Category

Rusty spikes

Wednesday, July 15th, 2009

NHibernate.Remote was one of my favorite projects.  Please note the word “was”.  The initial concept was exciting and early forays into coding provided positive results, however as with all concepts the devil is in the details.  In the end it was the lack of being able to extend the NetDataContractSerializer that really killed the project.  Not being able to analyze objects as they came over the wire led to a large amount of brittle reflection.  This led to problems synchronizing objects bidirectionally.  NHibernate.Remote was in reality a leaky abstraction on top of another not quite as leaky abstraction.  As I don’t have infinite time at work I have shifted focus to other ways of getting data out to clients.  I will probably leave the source online in case someone else wants to check out the concept but as far as I am concerned the project is dead.

Version is Out!

Friday, October 24th, 2008

Ok I’ll admit that it’s a bit later than I would have liked, but the next version of NHibernate.Remote is out.  While I’m sure that you’d like to read a lengthy article about blah this, blah that, and how hard it was with all of the other demands at work; I just don’t feel like writing all that out here.  So let’s just start of with a list of things that have changed.

  • Linq queries are now supported
  • Criteria queries are now supported
  • All new enities can now be saved
  • Entities on the client are change tracked and the changes are automatically submitted with a flush
  • Many more methods of ISession are now working
  • Better session concurrency

However there are still things that are being worked on, most noteably.

  • Transactions
  • Filters
  • Named queries
  • Sql queries
  • Change tracking on collections
  • Attatching transient entities

For a more complete list check out the documentation.

The underlying mechanisms have changed and evolved considerably since the last version.  However bear in mind that because of the vast number of entity combinations and queries, I haven’t had a chance to write tests for every senario, especially the more complex ones.

If you are adventuresome, grab the binaries or the sample project from the downloads page and give it a try. This version requires NHibernate 2.0.1GA and if you are using the binaries only, you will also need Post Sharp.

Serialization bites again.

Thursday, October 9th, 2008

I’ve been back working on NHibernate.Remote for the last week since I finished some of the more urgent updates for the company where I’m working.  I’ve come to the sad realization that the path I’ve been treading with the initial NHibernate.Remote codebase just won’t cut it for several reasons.

1) NHibernate needs a session factory.  You just can’t operate remotely or locally without a session factory.  Initially my goal was to transfer the required factory information across the wire to the remote client. However this approach doesn’t work very well as SessionFactory information is deeply nested and not conducive to serialization.  So I’ve opted for the next best thing which is to create an identical session factory on both ends of the wire.  That way both the server and the client can be aware of Entities, Collections and Proxies.  The only thing that the remote session factory does not get is a connection string, so it cannot be used to open a direct database connection.  So far this has been working fairly well and has enabled me to get both Criteria queries and NHibernate.Linq queries working over the wire.

2) That was the good news, now for the bad news.  The remote client simply needs to be aware of the entities that it is holding.  That means that every time an entity or a collection comes in over the wire it needs to affect the persistence context.  If this can be implemented flushing the remote session will become much easier.  I thought that the ObjectGraphWalker that I had created would be up to this task but once again I appear to be mistaken.   One of the requirements  I need is that I need to be able to replace an entity as I walk the object graph.  Let me explain further.  In a local NHibernate session if you query an object, change some properties and then query that object again, NHibernate is smart enough to detect that it already has that entity and will return to you the original changed object.  I need to do that remotely, thus the requirement for substituting objects when I walk an incoming graph.  That is simply impractical with the way that the ObjectGraphWalker works.

So I’m back to needing custom access to the inner workings of a serializer. I’ve tried to hack my way into the NetDataContractSerializer but with little success.  Surely my requirement is neither original or unique and Microsoft would do well to provide more open access to their serialization techniques.  Most likely I’ll just have to use reflector to extract the functionality that I need.  Sigh.

Riding out the bumps

Thursday, August 14th, 2008

Sometimes a person just has to wait for things to settle down before work can be done.  In this case I’m talking about NHibernate 2.0.  I had been building off of the latest stable release, beta 1, 2, CR1 etc…  However beta 2 seriously broke a bunch of things I’ve been working with as well as Linq support and I’m not sure yet what they intend on doing about it. For instance the latest stable release CR2, has added quite a few new methods to the ICriteria interface that is heavily used by both myself and Linq.  One would think that I could just add those methods into the classes that implement them and be done with it, however there is a further snag.  The latest SVN source of NHibernate (I would assume this is what NH 2.0 is being developed from) contains an ICriteria interface that is totally different than the one in CR2.  So which version is out of date and which one should I use?

Long story short, I’m going to have to wait a bit for the dust to settle before I can reliably continue building against NH 2.0.  Ahh but that’s the open source life.

NHibernate.Remote update coming soon

Monday, July 21st, 2008

The summer air is getting warmer and I’d rather be outside than inside coding.  However that hasn’t stopped work on NHibernate.Remote.  Several major changes are in the works and should be out shortly.

1) The generic messaging layer has been improved, unit tests and documentation have been added.  It is also now much faster.

2)Support for Criteria Queries and hopefully Linq is being added.

3)Better support for saving entities  with non Guid keys.

So if you have been wanting to give this a try,  you may want to wait a week untill the next version comes out.