Spring 3.1,Hibernate 4,SessionFactory [英] Spring 3.1, Hibernate 4, SessionFactory

查看:88
本文介绍了Spring 3.1,Hibernate 4,SessionFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是行得通的:

This was working:

<bean id="sessionFactory"  
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
...

但升级到上述版本会打破它。什么是创建 SessionFactory的正确方法 Spring 3.1.Release Hibernate 4.0.0.FINAL

but upgrading to the aforementioned versions breaks it. What is the correct method to create a SessionFactory bean with Spring 3.1.Release and Hibernate 4.0.0.FINAL?

部署错误:
$ b

The error on deploy is:


嵌套异常是java.lang.NoClassDefFoundError:
Lorg / hibernate / cache / CacheProvider;

nested exception is java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider;





编辑

已添加我自己的答案,它为我固定。


EDIT
Have added my own answer, which fixed it for me.

推荐答案

我认为你应该使用 org.springframework.orm.hibernate4 .LocalSessionFactoryBean 而不是
org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

I think you should use org.springframework.orm.hibernate4.LocalSessionFactoryBean instead of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

LocalSessionFactoryBean javadoc:


注意:LocalSessionFactoryBean的这种变体需要Hiberna te 4.0或更高。它在角色上与orm.hibernate3包中的同名命名类相似。但是,实际上,它更接近AnnotationSessionFactoryBean,因为它的核心目的是从注释扫描引导SessionFactory。

NOTE: This variant of LocalSessionFactoryBean requires Hibernate 4.0 or higher. It is similar in role to the same-named class in the orm.hibernate3 package. However, in practice, it is closer to AnnotationSessionFactoryBean since its core purpose is to bootstrap a SessionFactory from annotation scanning.

这篇关于Spring 3.1,Hibernate 4,SessionFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆