开发者

Is nHibernate intended to replace database objects?

I've not yet found a clear answer to this and to clarify:

With nHibernate and SQL server are you expected to disregard or migrate your busin开发者_开发知识库ess logic stored in your stored procedures, views and triggers into HQL or application code?


NHibernate is an O/R mapper which is very suited for applications that are build using a 'domain driven' methodology.
In such applications, the domain model is an expressive object oriented model of the business. This means that the 'model' contains all (or most of) the business logic.
In such cases, I see very little (if any) situations where you would put business logic into stored procedures.


Well, leaving aside all details: yes.

NH is an Object-relational mapper, and is intended to be used with an architectural style called 'Domain-Driven Design'. An important aspect of it is that it completely disregards the database for anything other than saving and loading data - this concept is called Persistence Ignorance, and its motto is: There is no database.

From this point of view, having business logic living in stored procedures or some other db object is not only discouraged, but it would clearly be a severe code smell.

If you follow the preferred Domain-Driven Design methodology, there will be just no opportunity to put business logic into the db - simply because there isn't any db around at the time of constructing your business layer...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜