开发者

Implementing a single Data Access Layer for Java and .NET

I have applications that have been written in Java, .NET and C++. They all use a common database.

Each app has it's own way of accessing the database, and so things are quite inconsistent.

I was thinking of writing a Data Access Layer using a ORM and having all applications use that.

The question is how to implement this ORM Data Access Layer:

  1. Make a Java package using Hibernate;

    use the Java package from the .NET and C++ apps

  2. Make a .NET class library using Entity Framework;

    use the class library from the Java apps

In either case, is it easy to access the package/class library from the other platform? Any suggestions on the path to take?

Is communicating via XML between the two platforms the best way?

Ps开发者_开发问答. I have already seen this question, but I think my question is a super-set of that one.

Ps. Making a web-service is an option, but I would prefer not to write/use a web-service.


iKVM

This will allow you to share code between .NET and Java. I like most sane people in the world prefer to write data access bits in .NET, but if you've got existing code in Java you want to make available for .NET services this is available

http://www.ikvm.net/

RESTful Web Service++

This is the most sane and obviously the quickest way to get up and running. Again, you could use something like Jersey, ASP.NET MVC, NancyFx or whatever REST application server you wanted to get up and running.

I would recommend you use NancyFx and ServiceStack.Text. These are two very simple very pure implementations and are extremely fast, which is what you want if you're using it as a unified DAL on top of your database.

Nancy: https://github.com/NancyFx/Nancy/

ServiceStack.Text: https://github.com/ServiceStack/ServiceStack.Text

Jersey: http://jersey.java.net/

ZOMG T3h H0rror - COM+ / DCOM

This is actually a viable possibility if you can't use RESTful web services, and also assuming you're exclusively on Windows. This will also be the most troublesome depending on how insane your requirements are. That being said, I've seen this done before and seen it work quite well especially when you have legacy C/C++ components living inside different segments if your infrastructure.


Is communicating via XML between the two platforms the best way?

This will have a performance issue - but will provide a unified data layer in a language independent maner. You can consider the open source WSO2 Data Services Server, if you select to go ahead with this approach...

Thanks...


It sounds a bit like the database can be thought of as a service that your various apps consume to different extents.

What about writing a web service layer to wrap all access operations to and service-enable the database? You could use ORM in that layer and have all of your applications interact with the web service wrapper. If you can deploy it on the same server as the database you won't get much extra network overhead.

I think this would be a decent cross platform approach where you don't have to depend on libraries across platform boundaries, and you've provided a standard way of talking to the DB for all current/future apps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜