最近做了个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+hbernate对clob、blob字段的处理 包括:数据脚本、典型的SSH框架处理,以及spring、hibernate数据批量保存等功能源码、所用到的lib包 数据环境为:oracle 10G 开发:Mycelipse5.1...
一个简单的Struts+Spring+Hibernate的登录模块的代码,含数据库代码和部分简单说明(适合刚接触Struts+Spring+Hibernate框架的开发者); 本例采用myEclipse6.0.1和tomcat6开发,可直接导入myeclipse工程运行...
毕业设计spring+struts2+hbernate博客系统源码+部署文档+论文
集合struts,spring,hibernate三大框架开发,是一个很好的项目实例
struts + DAO + Hbernate的脚本
最近入职一家公司,使用的 是springmvc框架,之前公司是用的struts2没接触过springmvc,所以这几天学习了一下并写了一个简单的基于注解的demo,数据库用的mysql,就两张表,有外键关联,demo实现了两张表的级联增删...
Spring-HBERNATE Spring -hibernate 与 mysql Spring-HBERNATE
自己昨晚上写的 但是没有加入验证码验证机制 数据库 chat 表名user 字段 id name pass
在线考试系统,用java编写,spring+hbernate的框架
struts+hibernate留言板(sh) list分页技术
自己用myeclipse开发工具写的一个sh的留言板,包括源代码和jsp页面(jsp页面写的很简单)
spring_Framework+经典SQL语句大全+Hibernate中文API
struts+hibernate+spring 增删改查实例,非常适合初学者
使用struts2+spring3.0+hibernate3.5实现的简单登陆
NULL 博文链接:https://xhfei.iteye.com/blog/691322
Hbernate的有源码的文件,可以帮助你学好hbernat
1 Database : use mysql5 2 Developer: MyEclipse 5 3 Liberary : J2EE1.4 + JDK1.5 + Hibernate 3.1 + Log + mySQL Build the normal Java Project and add the liberary to all the project....
hibernate一份不错的文档,比较适合开始学习或者不熟练hibernate的朋友
SSH快速搭建,spring1.2 struts hbernate
独自完成一个完整正确的SSH框架对于一个新手来说可能是一个相当困难麻烦的事。在此我利用Myeclipse+mysql环境下使用截图外加简略文字引导初学者一步一步的搭建出一个完整的SSH框架。图片及解说都存放在doc文档...