Thursday, May 15, 2008

NHibernate Odds and Ends

I have blogged about NHibernate in the past, and am going to talk about some odds and ends I have learned while using the tool on my current project.

First for the most part I love working with Nhibernate. Every time I have needed to add data access support it has been super simple to add. Everything is based off your Object Model so getting the data needed is a snap. Just open a session create a criteria, return your data, and close the session.

NHibernate logging works very well as well. it was easy to go in the log files and see what the tool really is doing. The one think to note is it can be very verbose and really slow down your application the more you log. For Production I would recommend ERROR only, otherwise you might find you app writing 100's of MB per page request.

One area I found a problem was in Like Querying. I was able to get Like working for smaller varchar columns Like city. An example would be Expression.Like(property, keyword, MatchMode.Anywhere). The problem I ran into for larger fields like say a comments field, it would not work. It could not match the keyword charming in a large varchar field even if charming was the only word. it was rather odd behavior and I was forced to write the SQL by hand and use the ISQLQuery created off the NHibernate session.

Just a side note, we are also using spring.net with our application and that is handling a lot of our configuration.

Again I cant talk about how much I enjoy working for the most part with NHibernate. It really does save development time when building applications.
Post a Comment