Spring怎样整合Hibernate Search?

问题描述

Spring.xml<!--......--><beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="mappingResources"><list><value>Bean/Person.hbm.xml</value></list></property><propertyname="hibernateProperties"><value>hibernate.dialect=org.hibernate.dialect.Oracle10gDialecthibernate.hbm2ddl.auto=updatehibernate.show_sql=truehibernate.format_sql=false<!--下面为hibernate的二级缓存的配置-->hibernate.cache.use_second_level_cache=truehibernate.cache.use_query_cache=false;hibernate.cache.provider_class=org.hibernate.cache.EhCacheProviderhibernate.search.default.directory_provider=org.hibernate.search.store.FSDirectoryProviderhibernate.search.default.indexBase=./src/Indexes</value></property></bean><!--......-->

Person.javapackageBean;import*****;@IndexedpublicclassPersonimplementsSerializable{@DocumentIdprivateStringid;@FieldprivateStringname;//setter,getter}

Spring+Hibernate是没有问题的。但加入HibernateSearch之后也是没有问题。FullTextSessionfts=Search.getFullTextSession(sessionFactory.getCurrentSession());这样就是不行。报错。org.hibernate.impl.SessionImplcannotbecasttoorg.hibernate.event.spi.EventSource

解决方案

解决方案二:
求回复!
解决方案三:
这个好像是类型转换失败的异常参考:https://forum.hibernate.org/viewtopic.php?f=9&t=1007329&view=previousIamusingeclipsefordevelopmentanddon'tseeanyproblemwithlogs.IcanprintstacktraceforothererrorsIthrowexplicitly.ButIagreewithyou,thattheprojectconfigurationcouldbeanissueorthattheremightbeaclassconflict.Iamrunningthisasastandaloneapplicationanddonthaveanyframeworkapartfromhibernate.ThisisjustlikeaPOCwhichIamdoingbeforeIactuallymovethattomywebapplication.However,Ihaveobservedthatmyprojectdoesntcompilewithouthibernate3.jarandhibernate-core-3.3.1.GA.jarbothinclasspath.WhenIremovehibernate3.jarfromproject,ithasissuecreatingSessionFactoryobjectandthrowsnullpointerexceptionforsessionobject.IfIremovehibernate-core-3.3.1.GA.jarithasissuewiththeEventsourceobject.DoesthatproblemmakessensewiththejarsIamusing?可能和你hibernate版本有点不配合
解决方案四:
对的。是类型转换失败了。我看了上楼发的网址。但是还是没有解决。
解决方案五:
应该用sessionFactory().openSession();

时间: 2024-10-01 09:37:10

Spring怎样整合Hibernate Search?的相关文章

spring mvc 整合hibernate 菜鸟级问题

问题描述 小弟想用spring mvc 整合hibernate 但是spring总是如法注入. spring配置文件如下<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">&l

基于注解的Spring MVC整合Hibernate(所需jar包,spring和Hibernate整合配置,springMVC配置,重定向,批量删除)

1.导入jar 2.web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4"  xmlns="http://java.sun.com/xml/ns/j2ee"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocatio

SSH笔记二 整合hibernate和spring

重新整理起来才发觉,搭建一个SSH框架是件很繁琐的事情.不过总觉得自己搭建的用起来才觉得得心应手,所以尽量的从中来发现一些乐趣. 今天的任务是--整合hibernate和spring.完成的效果如下(左边为包视图.右边为文件视图): 1.准备工作(用mysql5新建数据库,暂且命名为ssimdb) 1.1 安装mysql5(略),安装完成之后可以使用Navicat8来进行管理mysql: 1.2 创建数据库 ssimdb: 1.3 创建表 ssim_user 1 drop table if ex

ssh整合-spring整合hibernate做测试时没有报错,当三个整合时启动就报错啦,求大神指点!!

问题描述 spring整合hibernate做测试时没有报错,当三个整合时启动就报错啦,求大神指点!! 报的错误org.springframework.scheduling.quartz.JobMethodInvocationFailedException: Invocation of method 'ecsUnsigned' on target class [class $Proxy17] failed; nested exception is org.springframework.tran

java类的问题哈哈哈哈-hibernate和spring怎么整合的

问题描述 hibernate和spring怎么整合的 hibernate和spring添加切面配置是如何搞得,请各位大神指点我,谢谢啦 解决方案 http://wenku.baidu.com/link?url=JWek_B9UHh9ZkM1l80KvA1nmq6ePWUTq94zbWQVTe_2rL89R-pWdR3y3uBM5m2aRZBcruy2k2jsniuR3CTUtbLeoGbG4UswO6qECEumiFzu 解决方案二: http://blog.163.com/cui_zhouya

spring整合hibernate出现sessionFactory的bean创建异常错误

问题描述 spring整合hibernate出现sessionFactory的bean创建异常错误 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

spring 整合hibernate出错

问题描述 spring 整合hibernate出错 <?xml version ="1.0" encoding ="utf-8"?> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.

java-测试Spring整合hibernate/Struts2框架时,配置文件报奇怪的错误,求解

问题描述 测试Spring整合hibernate/Struts2框架时,配置文件报奇怪的错误,求解 为什么会报无法识别property? 解决方案 怎么都是这种问题,property要包含在bean标签内 解决方案二: Struts2+hibernate+spring整合时错误Struts2+hibernate+spring整合时错误 解决方案三: http://iteye.blog.163.com/blog/static/186308096201210265334689/ 解决方案四: pro

初次整合hibernate和spring,不能自动生成表

问题描述 初次整合hibernate和spring,不能自动生成表 以下是主要代码: Users类: package com.merlin.beans; import org.hibernate.SessionFactory; public class Users { private String id; private String name; private String password; public String getName() { return name; } public vo