• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

Can I use Hibernate for partial database migrations?

Hello,

a hibernate newbie with a question:

I have an oracle database that is used in a client-server application (using Delphi).
I plan to migrate to a Java EE / Spring architecture using Hibernate as a persistence framework.
For this I would reverse engineer the existing oracle database (probably using hibernate tools in eclipse, this is ok and not part of the questions here)

And I would like to continue running the legacy system against the database.
The plan is to migrate one usergroup after another to the new architecture, this to avoid having to migrate the whole application at once.

Questions:
* is this coexistence of one database running with the legacy CS application AND the new hibernate-based application possible? Do you see problems? Where? Any particular points to consider in Hibernate?
* what have other readers done to solve a similar problem?
* Do you see alternatives to Hibernate (in the java world, if possible using the Spring framework)?

Big questions, important questions, hence 500 points :)

Thanks a lot & regards,

Daniel
0
waeberd
Asked:
waeberd
  • 3
  • 2
1 Solution
 
Dejan PažinHead of SW DevelopmentCommented:

* is this coexistence of one database running with the legacy CS application AND the new hibernate-based application possible? Do you see problems? Where? Any particular points to consider in Hibernate?

One thing you have to watch out for is how the primary keys are acquired - to avoid any conflicts due to two systems running on the same table. Basicly you have to first find out what system is being used on the old application and what Hibernate will use and then think about possible conflicts.

* what have other readers done to solve a similar problem?

To avoid such problems we decided at the start of development that server and Hibernate are single point of entry to our database.

* Do you see alternatives to Hibernate (in the java world, if possible using the Spring framework)?

There are other persistence frameworks, but i dont think any of them match the power of Hibernate. Some of them might be simpler in some aspects, but considering the task you described, that is not what you need.

Here is a list of such frameworks:

http://java-source.net/open-source/persistence

0
 
waeberdAuthor Commented:
Thank you dejanpazin,

One thing you have to watch out for is how the primary keys are acquired
Primary keys are systematically acquired using oracle sequences, I plan to reuse the same sequences.

...we decided at the start of development that server and Hibernate are single point of entry to our database...
Does that mean you have exactly  two points of entry, one for the legacy server and one for the Hibernate-layer?

There are other persistence frameworks, but i dont think any of them match the power of Hibernate
Good, thank you! We have many tables and some performance-critical SQL-queries.

One other thing is:
I will use reverse engineering to build up the hibernate layer. This has consequences on the design. Somehow, the common database is the master for the persistence layer. In a perfect ORM world (you know: where 50 devs can start from scratch at once....  :-) ) the opposite is often the case: Objects are master over the database.

How does Hibernate "live" with this real-life constraint of reverse engineering?

Thanks, Daniel
0
 
Dejan PažinHead of SW DevelopmentCommented:


>> Does that mean you have exactly  two points of entry, one for the legacy server and one for the Hibernate-layer?

No, it means we never have legacy system simultaniously with the new one. We make the transition in one step and only have one system at a time.

>> We have many tables and some performance-critical SQL-queries.

You have to be very careful using Hibernate when it comes to performance. The programmers who work with Hibernate have to know exactly what happens in the sql layer, otherways you can run into havy performance issues. But since you already have the database that wont be such a big issue - you just have to rewrite the queries.

>> In a perfect ORM world (you know: where 50 devs can start from scratch at once....  :-) ) the opposite is often the case: Objects are master over the database.


Even in a perfect ORM world there are debates no which approach to use. Using the relations to objects gives you good control over performance issues. The other way around gives you better view of object hierarchy.

>> How does Hibernate "live" with this real-life constraint of reverse engineering?

It will live just fine, but you have to take good care of it - meaning dont leave anything to coincidence, check all objects, know what is going on in the sql layer, manually improve things where needed.


0
 
waeberdAuthor Commented:
No, it means we never have legacy system simultaniously with the new one. We make the transition in one step and only have one system at a time.

Not sure if we have the same architecture in mind:
In my "blueprint":

there will be exactly one database server
The old clients don't use hibernate but will continue to access the oracle database directly
The new application server will be build using hibernate.

So the "legacy" is rather the usage of the old clients. Already today the system is used concurrently, locking and primaryKey-IDs are handled on the database server.

You have to be very careful using Hibernate when it comes to performance. ... But since you already have the database that wont be such a big issue - you just have to rewrite the queries.

The key is that it is possible to rewrite the critical queries while not having to write all the boilerplate code. I read from your post that this is absolutely possible using Hibernate.
And still hard work of course. No silver bullet...

Thanks dejan, I feel confident now :-)

0
 
waeberdAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now