This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Database Query using Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Database Query using Hibernate" Watch "Database Query using Hibernate" New topic

Database Query using Hibernate

Rahul Solanki

Joined: Aug 02, 2011
Posts: 4
We are working on a migration project. Currently we are using stored procedures for fetching the data which uses linked servers to fetch cross server data. Below is a query to give you some idea.

Please suggest the best way to implement this using Hibernate. Thanks in advance for any suggestion.

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Hi and welcome to the JavaRanch.

Since you haven't put in a lot of effort in your post I'm not expecting that people are going to help you out a lot. You could start by telling us what you have done so far or what you're planning to do and why. Then we could give you suggestions about how to implement it in another/better way.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Rahul Solanki

Joined: Aug 02, 2011
Posts: 4
Currently we have 2 databases on our system where we are using linked servers (SQL SERVER) to fetch the data from both the servers (Cross database query).

In future we would like to move our Database from SQL Server to MySQL and thus we does not won't to use native sql or stored procedures as it will add extra efforts for the database migration project.

Now I am trying to implement hibernate using POJOs but my cfg files are pointing to 2 different servers. How can I achieve connectivity between 2 different databases or querying between 2 different database tables.

Please suggest how to achieve or suggest a better way of doing it.

Sandeep Kumar B
Ranch Hand

Joined: Jul 10, 2011
Posts: 45
Did you try using NHibernate?
It works well with multiple databases
I agree. Here's the link:
subject: Database Query using Hibernate
It's not a secret anymore!