请教:spring+hbernate search+spring mvc建立索引问题

最近做了个hibernate search搜索,但出现了一个问题,就是save()时不能建立索引(保存时有'刘宗安'这个数据的), 我用下面的代码:

  Query query = parser.parse("刘宗安");
   org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, clz);
   result = hibQuery.list();

 查询不出来啊,result返回0,但保存时在我的索引目录下自动新件了一个文件(好像是索引文件,但是查询不出来),现在用代码手动方式建立索引

List<SubPhoto> subPhotoL = super.getObjects();
      for (SubPhoto subPhotoIndex : subPhotoL)
     {
            fullTextSession.index(subPhotoIndex);
      }

 再进行查询,result就有数据了,但我发现我删除一条记录时,可以删除索引(我测试过了)

我的jar是:hibernate-annotations-3.3.1.GA    hibernate-search-3.0.1.GA  hibernate-3.2.6.ga

spring2.5

我不知道是否要加这个Listener(我没有加)

<hibernate-configuration>
<session-factory>
...
<event type="post-collection-recreate"/>
<listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>
<event type="post-collection-remove"/>
<listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>
<event type="post-collection-update"/>
<listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>
</session-factory>
</hibernate-configuration>

 好像下面一句话说,不用加了listener

Those additional event listeners have been introduced in Hibernate 3.2.6. note the FullTextIndexCollectionEventListener
usage. You need to explicitly reference those event listeners unless you use Hibernate Annotations
3.3.1 and above.

是不是这样啊?????

你可能感兴趣的:(spring,mvc,Hibernate,qq)