开发者

Migrating application context configuration to Spring 3.1 and Hibernate 4.0

I'm having hard time finding migration docs. I was using sping 3.0.5 and hibernate 3.4.

I migrated to the latest release candidates: spring 3.1 and hibernate 4.0

I was able to refactor my classes without problem but the application context for hibernate is giving me problems since I have not see any examples on how to configure it.

Specifically:

<bean id="sessionFactory"    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
        <list>...</list>
   </property>
    <property name="hibernateProperties">
        <props>
          ... 
          <prop key="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</prop>
          <prop key="hibernate.cache.provider_class">????<开发者_运维知识库;/prop>
          ...
        </props>
    </property>
</bean>

Apparently properties dataSource , mappingResources and hibernateProperties no longer exist and I'm not so sure about what to put in hibernate.connection.provider_class and hibernate.cache.provider_class.

And I keep getting:

Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition

at application start.


To my knowledge, Spring has no support for Hibernate 4. If it did, I'd expect to see an org.springframework.orm.hibernate4 package in the 3.1.x package list, but it's not there. I don't believe I've seen any mention of it in any release notes or anything, either.

In other words, Spring is working fine, but you're using an incompatible version of Hibernate.


dataSource still exists, based on the JavaDoc for LocalSessionFactoryBean. See the section at the very top; it has an example config with a dataSource property. mappingResources also exists.

The Spring 3.1 reference guide also has an example, with dataSource and mappingResources.

Hibernate 4 does not have a ref guide yet.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜