Solved

Can I use Hibernate for partial database migrations?

Posted on 2011-03-06
5
496 Views
Last Modified: 2012-08-14
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
Comment
Question by:waeberd
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 35053964

* 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
 

Author Comment

by:waeberd
ID: 35054152
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
 
LVL 17

Accepted Solution

by:
Dejan Pažin earned 500 total points
ID: 35054371


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

Author Comment

by:waeberd
ID: 35054696
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
 

Author Closing Comment

by:waeberd
ID: 35069424
Thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now