Yes, I know ist is a little bit "dangerous" to tell about a found bug, but I think i really found one.
If not, please don´t be angry...
This is the situation:
I use:
Hibernate Core 3.2.3 GA
Hibernate Annotations 3.3.0 GA
Hibernate Search 3.0.0 Beta1
Hibernate Mappings are made in *.hbm.xml, not with annotations, my hibernate.cfg.xml contains the following:
Code:
<!-- Konfigurationen für Hibernate Search -->
<property name="hibernate.search.default.directory_provider">
org.hibernate.search.store.FSDirectoryProvider
</property>
<!-- Ende Konfigurationen für Hibernate Search -->
....
<event type="post-update">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-insert">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-delete">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
Now I try to Index this structure:
Code:
@Indexed
public class TEvent implements java.io.Serializable {
// Fields
@DocumentId
private Long eventId;
@IndexedEmbedded
private TAgent TAgent;
private TArticleType TArticleType;
@IndexedEmbedded
private TLocation TLocation;
...
}
public class TAgent implements java.io.Serializable {
// Fields
@Field(index = Index.UN_TOKENIZED)
private Long agentId;
@Field(index = Index.TOKENIZED)
private String name;
private Set<TSystemEvent> TSystemEvents = new HashSet<TSystemEvent>(0);
@ContainedIn
private Set<TEvent> TEvents = new HashSet<TEvent>(0);
....
}
/* Indexing: */
@Test
@Categories({"hibernate"})
@SuppressWarnings("unchecked")
public void indiziereTevents()
{
List<TEvent> eventList = new TEventHome().findAll();
FullTextSession fullTextSession = Search.createFullTextSession(HibernateUtil.getCurrentSession());
Transaction transaction = fullTextSession.beginTransaction();
for(TEvent event : eventList)
{
System.out.println("********* event.getTAgent().getAgentId(): " +event.getTAgent().getAgentId());
System.out.println("********* event.getTAgent().getName: " +event.getTAgent().getName());
fullTextSession.index(event);
}
transaction.commit();
}
Now for example, I will only have the field TAgent.Name in the lucene index, when TAgent is fetched eager:
Code:
TEvent.hbm.xml:
<many-to-one name="TAgent" class="com.......hibernate.core.pojo.TAgent" fetch="select" lazy="false">
<column name="AGENT_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
this won´t work:
Code:
TEvent.hbm.xml:
<many-to-one name="TAgent" class="com.......hibernate.core.pojo.TAgent" fetch="select" >
<column name="AGENT_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
Even when I Print out the fields to index with System.out (then they are loaded, lazy or not) bevor doing fullTextSession.index(event); they won´t be in the index.
Perhaps this is a bug, or I made a mistake (where could it be?).
Perhaps someone knows a workararound.
btw Another thing is, that I cant index more than one time "embedded":
http://forum.hibernate.org/viewtopic.php?t=973864
, perhaps a bug to? (Or both is my mistake...)