Bumbler: NHibernate Dynamic / Interactive Shell

time to read 7 min | 1271 words

After reading a bit about Jasper, I decided that I would like to see what it would take to build it with NHibernate and Boo. I am going to implement it and write the post at the same time, so you would get near real time documentation of the process.

  • 18:05, decided that I want this syntax:

    import Bumbler

     

    conStr = "Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True;";

     

    bumble = Bumble.Through(conStr)

    for customer in bumble.Customers:

          print "Customer ${customer.ContactName}"

    c

    = bumble.GetCustomer("TRADH")
  • 19:10, finished building client interface and quick & dirty mapping from database implementation.
  • 19:24, finished code generation, now working on runtime compilcation...
  • 19:54: finished runtime code generation
  • 20:13, can now successfully query the database using NHibernate just from connection string. Starting to work on dynamic implementation.
  • 20:16, done basic dynamics, now playing with Booish.
  • 20:21, the code above now works, and I am going for dinner.
  • 21:10, back from dinner, final polish...
  • 21:13, done!

So, about two hours of work, most of which had to do with generating the mapping from the database. I have cut some corners there, so it is SQL Server only, and it can't support a legacy app, adding support for the more complex cases is simply adding it to the mapping generation, nothing else. I made sure that adding new functionality would be easy, however.

Right now, you can get the code, just run the application, and you will get a shell that you can use to interact with the objects and the database. You need to start a new Bumble (you can simply cut/paste the code above) and then play with it. You can also reference the assembly and work with it directly using Boo.

Getting the code:

svn co https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/SampleApplications/Bumbler