-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Search with multiple datasources and entities
PostPosted: Mon Jul 04, 2016 6:56 am 
Newbie

Joined: Mon Jul 04, 2016 6:37 am
Posts: 1
First of all I would like to say hello to everyone. This is my first post here. Hibernate is an awesome project.

Anyways, I would like to ask if anyone has done something similiar, has ideas or knows a solution.

The task was to do a search that consumes different databases. The database-entities contain different information that will be listed in a search. So what I did was I created multiple EntityManagers and created multiple search-queries one for every database. So when a query is made with an EntityManager you can only query Entities in that current database.

What I have now is multiple ResultLists and combining them seems to be hard without breaking the hibernate Sorting. So currently I'm just merging multiple object-lists and using Collections.sort() to sort all the minor list into a one final search result that gets printed out.

Might there be any possibilities to query for Entities from different databases in single query?

Any other solutions are also being accepted.

Hope that made any sense.

Best regards,
Matias


Top
 Profile  
 
 Post subject: Re: Hibernate Search with multiple datasources and entities
PostPosted: Wed Jul 13, 2016 4:04 am 
Newbie

Joined: Tue Apr 19, 2016 6:24 am
Posts: 5
Hi,
As per my knowledge, i have not seen such cases where querying to the multiple tables is done using Hibernate(may be i have a very small career with hibernate).

I can tell you a work around for this. You may follow the below steps:

1. Create the view of the other database tables to a single database tables(you can use database links to do so).
2. Create POJOs for the tables(which, i guess, would already be present as you are able to query those tables).
3. As now all the tables exist in the same database(as database views), you may use a single query to query all the tables at once.

Remember, do not drop the tables while creating the hibernate session factory.

Regards,
Keshav


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.