-->
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: Auto Index Transient fields
PostPosted: Wed Oct 28, 2009 5:33 pm 
Newbie

Joined: Tue Jul 22, 2008 11:30 am
Posts: 13
Hi,

I have a case where i need to index data in my entity via methods that are marked @Transient. Indexing them is no problem, but i'm hoping to get some ideas on how to maintain them in the index. Basically i want to tie a @Transient method to something being persisted to the database.

For example:
Code:
...
@column(name="foo")
public Foo getFoo()
{
return foo;
}
public void setFoo(Foo foo)
{
this.foo = foo;
}

@Transient
@Field(name="isFooFoo")
public boolean isFooFoo()
{
  return (foo == bar);
}
...


When i manually index, isFooFoo gets set. What i would like to do is auto index isFooFoo when the foo column is updated.
What are some of my options here?

Thanks!


Top
 Profile  
 
 Post subject: Re: Auto Index Transient fields
PostPosted: Wed Oct 28, 2009 6:59 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
This should work without changes. Did you try it?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Auto Index Transient fields
PostPosted: Wed Oct 28, 2009 10:17 pm 
Newbie

Joined: Tue Jul 22, 2008 11:30 am
Posts: 13
i thought i had tried it, but i can double check tomorrow morning. I guess i'm not too clear why the @transient method would be called for auto indexing.

Just to make sure there is no confusion, indexing isFooFoo is zero problem. I'm pretty sure i'm having issues when the foo column is updated and isFooFoo is not being redone.

Does Hibernate Search just go through and reindex all the @Fields/@indexembedded for a particular Enity when that entity has an update/insert/etc performed on it? Or does it know that column xzy was udpated and it was marked with @Field so update the index for that particular field?


Top
 Profile  
 
 Post subject: Re: Auto Index Transient fields
PostPosted: Thu Oct 29, 2009 6:12 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Does Hibernate Search just go through and reindex all the @Fields/@indexembedded for a particular Enity when that entity has an update/insert/etc performed on it?

exactly

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Auto Index Transient fields
PostPosted: Thu Oct 29, 2009 8:56 am 
Newbie

Joined: Tue Jul 22, 2008 11:30 am
Posts: 13
Thanks for the information on some of the inner workings of Hibernate Search!

I double checked my code and sure enough it works! It wasn't being indexed because the data was being updated directly via a query instead of through the entity (the joys of old code)

Thanks again!


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.