문제

I am new to NHibernate and was thinking to use it in a project which could support different database like (Oracle, MySQL, SQl Server, DB2 etc..) as this product might be shipped to different clients who could use different datbases as per their choice. However schema of different database would remain same.

As we know that NHIbernate provides out of box support to many databases, i have below doubts

1) Do we need to specifically install the individual database drivers or they come with NHIbernate setup? I could not find any drivers with the NHibernate installation files

2) Is it possible that by only changing the configuration settings etc my application can talk to different databases? i.e no code change apart from config settings would be required if code is sent to client who might be using any one of oracle/DB2/SqlServer database etc ?

도움이 되었습니까?

해결책

Answering your questions:

1) No, NHibernate does not ship drivers. You have to look for them elsewhere. I, for example, use Npgsql with PostgreSQL.

2) It is very possible by changing your driver and your connection string to start using a different database without major problems (also by avoiding db specific mappings such as sequences or identity for id generation). I have migrated from SQL Server to PostgreSQL very recently; just so you have a notion of how well it went, the migrated product was querying over 70 tables with the HQL, Criteria and Linq APIs of NHibernate and we only had a problem with the collations being different in both databases, which does not concern NHibernate at all. In my opinion, as long as you stick to NHibernate for querying, you'll be safe.

Since you're leaving the choice of the database to your client, I would recommend you list and recommend only a few select databases. Your clients just might run across a bad driver, for example.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top