-->
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.  [ 5 posts ] 
Author Message
 Post subject: Keep index up to date considering non-hibernate db changes
PostPosted: Thu Aug 28, 2008 7:59 am 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
I'm using Hibernate Search with Annotations. I've created the index and have added the listeners so the index stays up to date when changes are made through the annotated entity. My problem is that we often have to run some update queries manually on our db because our application isn't fully developed for all functionality yet.

Is there a way, other than deleting the whole index and re-creating it, that we can keep the index up to date during non-hibernate updates??

Thanks so much for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 9:14 am 
Hibernate Team
Hibernate Team

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

do you have a way to identify the updated values? For example do you have a [i]lastModified[i] timestamp or something similar. If so you can use the batch indexing functionality, but you just retrieve the entities which have an updated timestamp.

BTW, are these queries native SQL queries? Bottom line is that you somehow need an entity. Be it for batch indexing or incremental updates.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 9:21 am 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
Well these are native SQL queries. We have a MS SQL Server 2005 db. We are literally opening Management Studio and executing queries to update data. Is there any way for hibernate to listen to changes to db tables that have an entity associated with them to keep the index updated?

...from what I've read I can't really see a way other than deleting the entire index and recreating it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 10:04 am 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
I think what I could do... maybe give me your feedback on this.

We need to run queries directly on the database for various tasks.
What if I created a function in my hibernate class that excepts a sql query as a string.
I can then create a separate page that only has a textbox and a submit button. I can place whatever sql code I need to execute in the textbox, click submit, and have it call the hibernate function with the passed sql code. That way, if its done inside the hibernate entity, the listener will pick it up.

Thoughts?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 10:34 am 
Hibernate Team
Hibernate Team

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

If you are talking about using Hibernate's native query support you are still having the same problem. Yes, you can trigger any native query from within Hibernate, but that does not mean that Hibernate automatically knows which entities are effected by the query.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.