這似乎是一個常見問題,但我無法解決它。 我的春節3.1.1配置hibernate4.LocalSessionFactoryBean無法轉換爲org.hibernate.cfg.Configuration
<bean id="sessionFactoryEditSolution" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="editSolutions-pool"/>
<property name="mappingResources">
<list>
<value>/editsolutions.hibernate.cfg.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
<prop key="net.sf.ehcache.configurationResourceName">/ehcache.xml</prop>
<prop key="hibernate.max_fetch_depth">6</prop>
<prop key="hibernate.default_schema">dbo</prop>
</props>
</property>
</bean>
這怎麼我試圖獲取配置對象
Configuration editSolutionsConfiguration = `(Configuration)AppContext.getBean("&sessionFactoryEditSolution");`
起初我有休眠3我的應用程序,但它與Spring 3.1集成.1我已將它升級到Hibernate 4。這就是爲什麼我必須在我的lib文件夾中保留hibernate3.jar以支持少數hibernate 3特定代碼行。
運行具有多個版本的相同jar的應用程序將無法工作。 –
@PauKiatWee那麼有什麼辦法可以用Hibernate 3來實現Spring 3.1.1,或者將Hibernate 3特定的類遷移到Hibernate 4嗎? –
我已經做了這個快速代碼轉儲:http://www.matthews-grout.co.uk/2012/04/hibernate-4-and-spring-3-configuration.html – Dan