The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

NHibernate

Please if you have experience with this - tell me about your experience. (ASP.NET 2.0)

Thanks
Steve Send private email
Thursday, March 02, 2006
 
 
I started using NHibernate about 3 weeks ago and managed to set up a quite complex site (about 12 database tables) in about two weeks, along with the frontend templating and stuff.

This is a really good technology with relatively small learning curve, if you have previous experience in Object-Relational Mapping.

While the documentation is crappy, the Java's version documentation is very good and helpful, so I can recommend this.

The only thing is the performance, since I'm new to .Net some of my pages are loading in e.g. 1.4 seconds, which doesn't satisfy me, but I'm not sure what causes it.

VS2003 doesn't have a decent profiler so it's hard to immediately tell what causes the bottlenecks.

PS. Sql Server 2000 is crap - it doesn't allow you to paginate through the results, like select * from clients limit 10,10 - hence it might be slow for navigating through large datasets.
Marcin Send private email
Friday, March 03, 2006
 
 
like marcin said, there are a couple of things that hopefully be ironed out later on like the pagination, but this is still possible with a bit of seperate code in your datalayer.

i've been using nhibernate with v2 of asp.net and dont have any complaints about this but the sites I have developed have been relatively small but as far as integration with .net V2 it seems fine.  Look at the codus tool by adapdev which is free and basically allows you to pick your db tables and then with a few clicks it will create your c# classes, layers and nunit testing ! brilliant !
Andrew Deakins Send private email
Friday, March 03, 2006
 
 
I just sat through a presentation on using NHibernate with C#. It looked decent. My biggest complaint was that it sounds like you are required to do all SQL selects using their proprietary HQL language. I'm wondering if the presenter was correct on this topic. Is it possible to query the database using regular SQL or do I have to use HQL all of the time? Is there anyone using it that can answer this? After all, the last thing I need is one more stupid language to have to learn.
Turtle Rustler
Friday, March 03, 2006
 
 
I am working on a decent rich client project by using C#/NHibernet. It's pretty cool especially for me, an OOP lover. The most elegent way to do it, I think, is taking your business objects as central point of the program, persisting them with NHibernat, binding them with winform by using form databinding with objects. This approach will save you tons of time. Of course, at the beginning, there would be a learning curve. But, for the time being, it will very well pay you back.

You don't have to use HQL all the time. You can use native sql too. But to benefit from NHibernate, you better use OOP as possible as you can, because that is where NHibernat shines. For regular CRUD, you usually don't need to write one line of sql code, that is the beauty of ORM.

Bo

Friday, March 03, 2006
 
 
Thanks everyone - I appreciate your responses.

I have been using the DataTableAdapters with the ObjectDataSource to see how well they can work in a small asp.net 2.0 app.

However, I want to plunge into NHibernate - some Java friends spoke highly of Hibernate.

Thanks again
Steve Send private email
Friday, March 03, 2006
 
 
I've used NHibernate with ASP.net 1.1. Not 2.0 but same effect I guess.

You need to recreate the NHibernate session for each web request. This can be done through Http Modules. See http://www.benday.com/nhibernate/

Aside from that it is the same as a desktop app.

The super-huge pain in the arse problem I had was that the database used composite keys. Although NHibernate does support composite keys it does not support updating any of the key fields.

Always use an integer primary key. If the table represents a many-many join then add an incrementing integer surrogate key. ie {ID, StudentID, ClassID}

Databinding support in ASP.net (1.1) worked great with the nullable types library in the NHibernate contrib distribution. I didn't have a problem with any controls. In winforms some controls such as the textbox don't seem to handle nulls, although this can probably be easily dealt with by adding some implicit or explicit cast operators to the nullable types.

Mapping files: Add these as embedded resources and use reflection to find them.

Was it worth it -- Yes!
64 tables, 640 fields, no CRUD, no SQL, all autogenerated :)

Email me if you want code examples for Http modules and NHibernate session factory.
Kim Send private email
Tuesday, March 07, 2006
 
 
I strongly encourage you to try another O-R mapping tool - Sooda (http://www.sooda.org/). Sooda is certainly not as popular as hibernate/nhibernate, but I think it has some clear advantages. It is smaller, simple to configure and very easy to use. The tool has been used in several commercial projects by the company I work for and proved stable, bug free and fast. The testing was done mainly on MS SQL server, but it has also support for  other dbs.
Rafal
Friday, March 10, 2006
 
 
I've written an article concerning the use of NHibernate with ASP.NET:  http://www.codeproject.com/useritems/NHibernateBestPractices.asp.  I've used NHibernate for a very performance critical application (http://www.shipcompliant.com) and it did very well.  The project was about 50,000 lines of code with about 100 SQL tables.  We ended up having about 5 stored procedures for optimization reasons.  The rest we left to NHibernate.

Hope this helps!
Billy
Billy McCafferty Send private email
Wednesday, March 15, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz