-->
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: Accessing database from within a custom bridge
PostPosted: Mon Feb 01, 2010 4:15 pm 
Beginner
Beginner

Joined: Fri Jun 29, 2007 2:19 pm
Posts: 26
Location: Fremont, CA
I need to fetch some data from database, is there a way to inject dao dependency into the custom bridge or create bridge as spring bean and inject the Custom Bridge into the POJOs. I believe current parameterization for bridges, need to fulfilled when statically from POJOs and cant take spring bean name as parameters.

In general, is it a bad idea to retrieve data from DB in bridges. I need to convert IDs (which are properties in the object being indexed) into corresponding objects and let lucene index on the properties of those objects (and not on the IDs). How else can this be solved (if not bridge)

_________________
-shailesh


Top
 Profile  
 
 Post subject: Re: Accessing database from within a custom bridge
PostPosted: Thu Feb 04, 2010 8:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

here are some ideas. Since you did not give much context information about your application they might be more or less workable.

First I am wondering why the object you are trying to index does not define a association (OneToOne or whatever is appropriate) to this other object you want to load in the bridge? It could be a lazy loaded association there would really be no additional runtime cost. Why do you just store ids to some other objects and not real associations?

If you cannot use real associations you will need to get hold of the Session object or create a new one. I assume you have the whole Hibernate configuration wired up in Spring. As you say, you cannot configure your custom bridge in Spring. The best idea I have is to get hold of the Spring ApplicationContext within the bridge. Something like this could work http://blog.jdevelop.eu/2008/07/06/acce ... plication/

--Hardy


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.