Hi All,
I have been evaluating nHibernate for some time.
Overall, I liked the ORM concept and liked the way objects are populated and how relationships are managed.
However, my application has a SOA and I have been facing quite a lot of issues or maybe that I am not clear about these things.
As of now whatever major hurdles/issues/limitations/concerns I have faced/have, I have listed them below (Not just from a SOA perspective, but overall):
I) Performance:
1. If nHibernate default approach of dynamic SQL is used, performance tuning could become an activity for the application tier rather than the Database tier. Is it really recommened because if Stored Procedures are used, performance tuning can be done relatively easily in the database tier?
2. Sparse updates (using <dynamic-update>) are supported by nHibernate across a single nHibernate session. I could not come across any reference which shows how I can achieve the same across different nHibernate sessions.
3. Partial loading of objects is not supported. (I am not very concerned about this. However, would really love to have this feature).
II) Security:
1. nHibernate generates dynamic SQL. The kind of SQL it generates is prone to SQL injection attacks.
III) Custom SQL:
1. Results of HQL and custom SQL queries can be mapped to objects. However, the HQL and custom SQL has to be executed explicitly and is not seamlessly executed by nHibernate by reading them from the Mapping files and replacing the default dynamic SQL by these queries/Stored Procedure calls.
2. Even though, nHibernate supports Stored Procedures for CRUD operations, it puts various restrictions on the number and order of parameters of the stored procedures. Hence, custom parameters cannot be passed to the CRUD operations' Stored Procedures which may be required for implementing some custom logic (either complex or simple) inside the Stored Procedure.
3. Stored Procedures with custom/external(not part of the domain entity) parameters are supported by nHibernate.
However, The way custom stored procedures are supported, their flexibility cannot be used for nested objects because they cannot be called implicitly by nHibernate when populating the objects. I dont mind populating the top level objects explicitly. However, in scenarios where the child objects need to be populated using some custom condition/paramater using Stored Procedures, nHibernate doesnt support it seamlessly.
E.g. I have a Customer class which has an IList of Orders.
Suppose, I want to fetch only those Orders of a customer which have been ordered in the past x(x needs to be set at runtime) number of days and I also want to perform some security check(in the DB) based on some UserID (which is not an attribute of both the Customer or Order class). This security check needs some custom logic involving multiple SQL statements. Hence, I need to do this in a Stored Procedure which takes custom/external parameters. This Stored Procedure requires to be called explicitly using ISQLquery. Is there some way we can setup these kind of Stored Procedures so that they are called implicitly by nHibernate when I access my Customer.Orders property?
IV) General:
1. Documentation and samples are not available for complex/custom scenarios.
If anybody could address/have suggestions or workarounds for my concerns, I would certainly appreciate that because it would be of great help to me in deciding whether to use nHibernate or not in my DAL.
Also, I have not come across any documentation/article where the best practices for using nHibernate in a SOA have been described. I am specifically interested in how I can leverage (if at all) the features provided (like Lazy Loading) by nHibernate across different layers of my application. If somebody has any idea or can refer some article, that would be of great help.
Ending my long post with the expectation that I will get help from the very brilliant people over here.
Thanks!
Regards,
Indrajeet
Last edited by IndrajeetP on Tue Nov 21, 2006 9:02 am, edited 2 times in total.
|