Quote:
Retrieve and store ID
When saving new objects to tables that have a primary consisting of one field which also has identity, the value inserted in this field must be retrieved and assigned to a specific property of the object that's being saved (the ID property)
Yes. Very easy. The element in the hbm.xml file that determines this is the <generator> sub element of the <id> element. It also works against sequences or other key generation approaches. If one doesn't suit, you can create your own.
Quote:
One object, several tables
There isn't a one-to-one relationship between classes and tables. For the most part, this does not happen, but there are cases in which properties of one class may be saved to more than one table
If you are talking about fine grained objects, NHibernate encourages you to use a fine grained object model. Eg you may have a ContactInfo class used in say a Person and Company class. The underlying tables would have common columns. In the hbm, you'd use the <component> element to help manage the translation from your fine grained object model to the course grained relational model (if that's how you choose to represent the data). If you are talking about polymorphic relationships, NH also covers this situation.
Quote:
Audit trail
When persisting an object, it is sometimes necessary to write to an audit/history table with the primary key of the table that holds the actual object data, the current date, user and sometimes other data.
Yes.. with a bit of once off framwork area effort. Check out the NHibernate.IInterceptor interface.
Quote:
Property vs. Property.ID
When a property of the object being persisted is another custom class, it is sometimes necessary to submit the ID property of this class instead of the actual class. For example, say we have a class named Department which has an ID int property. Say we also have a class named Employee with two properties: an ID int property and a Department property of type Department. When saving the employee data, the table will require Department ID and Employee ID.
In NHibernate you submit the entire in memory object graph to the NHibernate Session's SaveOrUpdate method. You don't have to worry about any explicit manipulation of IDs yourself. NH will work out what is new (and insert it and give back the DB key value) what has changed (and update it) without need for any special dirty checking on your part in the domain model. The only "constraint" on the domain design is all methods and properties must be virtual so that NH can create proxies for you.
Quote:
sp_prepexec
Because of our database configuration, our applications cannot run INSERT, UPDATE or DELETE statements directly against it. The only alternative we have come up with is to use the sp_sqlexec system stored procedure (or, alternatively, sp_prepexec or sp_prepare and sp_execute) to execute the ad hoc SQL statements created by the ORM by passing the generated query as a string parameter, meaning we should be able to retrieve it and stop the ORM from executing it itself. Is there a way to do this? Can you think of a better solution?
I'm pretty sure (although someone can correct me if I'm wrong) this is either gonna be a deal breaker for you or will be a bit of ongoing work on your part (eg every time you add a new table the extra work around will have to be applied... kinda defeats the purpose of the ORM). NH generates ADO.Net SQL statements with bind variables ready to go for you by default.
Quote:
Versions and compatibility
The SDK we are building is for an application we publish....
I think it depends on how far ranging your changes are. But having one value type property (eg a string property) on a class to be stored in a completely different table to the rest of the value types in the same class is not going to be easy. On the other hand if you just don't need the column, removing it from the class (and hbm) is no problem.
I've used NHibernate for the last 3 years. Most recently on a project using around 140 tables and a domain model that is fine grained and also has polymorphic relationship mappings. I would recommend using NHibernate.