Archive for the ‘NHibernate’ Category

NHibernate error messages

November 30th, 2007

Those are just from today:

1. Can't write to a readonly object

No meaningful information on the call stack, not a single clue. Would it hurt to tell which object is marked as ReadOnly?

2. Could not instantiate cache implementation
Inner exception: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]


3. StaleObjectException

Note that I'm not using version/timestamp. Turns out that there was a call to update when it should be a call for Create.

Ayende recently blogged about Castle style errors. At least the more important ones try to tell you what happened, why and how to fix it. I decided upon this path due to two things

1 - When I used to work with Visual C++, most error messages included a clue "did you forget to turn option foobar?". Those were very helpful.

2 - In the early days of Castle I was setting up a project for a new client and everything collapsed. I had only an odd exception that didn't tell much. From that day on I vowed to never let that happen again. Can you imagine looking clueless in front of a client dealing with a project that you're supposed to know everything about?

NHibernate goes in other direction. Maybe they want that every user digs on the code base, become NHibernate hackers, or they just want to challenge you to make your life more interesting. I guess next version will include riddles with every error message: "Stale object exception: what gets wet as it dries?"