Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a single Data Access Layer for Java and .NET

Tags:

java

.net

orm

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.

like image 580
Zabba Avatar asked Sep 04 '11 06:09

Zabba


2 Answers

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.

like image 188
Anuj Avatar answered Oct 18 '22 12:10

Anuj


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...

like image 29
Prabath Siriwardena Avatar answered Oct 18 '22 12:10

Prabath Siriwardena