Implementing a single level of data access for Java and .NET

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

Each application has its own way of accessing the database, so everything is completely incompatible.

I was thinking of writing a data access layer using ORM and using all applications.

The question is how to implement this level of access to ORM data:

  • Make a Java package using Hibernate; use Java package from .NET and C ++ applications.

  • Create a .NET class library using the Entity Framework and use the class library from Java applications

In any case, is it easy to access the package / class library from another platform? Any suggestions along the way?

Is XML communication between the two platforms the best way?

Ps. I already saw this question , but I think my question is a super-set of this.

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

+6
source share
3 answers

IKVM

This will allow you to use code between .NET and Java. I like the most sensible people in the world who prefer to write data access bits in .NET, but if you have existing Java code that you want to make available for .NET services, this is available

http://www.ikvm.net/

RESTful Web Service ++

This is the smartest and obviously fastest way to get up and running. Again, you can use something like Jersey, ASP.NET MVC, NancyFx, or any other REST application server that you would like to start and run.

I would recommend you use NancyFx and ServiceStack.Text. These are two very simple, very clean implementations and extremely fast, what you need if you use it as a unified DAL on top of a 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 truly a viable option if you cannot use RESTful web services and also assume that you are exclusively on Windows. It will also be most unpleasant depending on how crazy your requirements are. This suggests that I saw this before and saw how it works very well, especially when you have legacy C / C ++ components living inside different segments, if your infrastructure.

+2
source

Is XML communication between the two platforms the best way?

This will have performance problems, but will provide a single level of data in a language independent wizard. You can consider the open WSO2 Data Services Server if you decide to continue this approach ...

Thanks...

+1
source

It sounds a bit like a database can be considered a service that your various applications consume to varying degrees.

How about writing a web service layer to migrate all access and database activation operations? You can use ORM at this level and interact with all your web service wrapper applications. If you can deploy it to the same server as the database, you won’t get any additional network overhead.

I think this will be a worthy cross-platform approach, when you do not need to depend on libraries on the platform boundaries, and you have provided a standard way to communicate with the database for all current / future applications.

0
source

Source: https://habr.com/ru/post/896574/


All Articles