user1997254
user1997254

Reputation: 25

Database migration with Hibernate

I am new to hibernate. Learning from internet source. As we know, with the help to Hibernate Dialect, we can easily migrate one database to another (for ex. DB2 To MySQL) i.e. only Java part we can migrate.

But how can migrate Stored Procedure and Indexing that are database specific? And can hibernate provide such feature to migrate?

Upvotes: 2

Views: 4505

Answers (1)

Rohit Gaikwad
Rohit Gaikwad

Reputation: 3914

Hibernate is used to store a java class object into database and retrieve it as it is. That is a ORM framework. What hibernate can help you in your DB migration as below:

1. By changing some properties like dialect, connection url, driver class etc will allow you to store/fetch the java class objects into the new DB that you are migrating to.

2. Reverse engineering: If you already have table structures (containing all the relationships between the tables) in your old DB then using reverse engineering you can create the POJO classes for hibernate.

Netbeans has built-in support for reverse engineering.
Hibernate Tool/Plugin can be used for Eclipse IDE to achieve reverse engineering.

Now, the stored procedure, triggers etc. created in your db are not from hibernate. It means hibernate have nothing to do with it. Because, the extra things (procedure, cursor, triggers etc) that are working on your database have some special purpose than a java application to store/manipulate/fetch data.

Hence, you can migrate from old DB to a new one but you won't need hibernate to migrate those extra things. Instead you can use some techniques or procedures like this Migrating Oracle Databases to SQL Server .

This things (stored procedures, triggers migration) can be done at database level and the java application has nothing to do with it.

Upvotes: 1

Related Questions