带有Hibernate 4.2.6 + Spring 3.2的EntityMode.Map [英] EntityMode.Map with Hibernate 4.2.6+ Spring 3.2
问题描述
我正在尝试使用动态hibernate模型,下面是获取session的代码片段。我将 hibernate.default_entity_mode
声明为 $ dynamic_map
在hibernate session factory config xml中。
//在类级声明
@Autowired
private SessionFactory sessionFactory;
//在特定的java-method
Session pojoSession = sessionFactory.getCurrentSession();
Session ds = pojoSession.getSession(EntityMode.MAP);
不过,我在eclipse中得到一个异常 - 方法getSession EntityMode)对于类型Session
未定义,但尝试从pojoSession获取dynamicSession。
我使用Hibernate 4.2.6 。最终核心和实体经理&弹簧3.2框架罐。
任何人都可以协助我做错了什么?
更新:类似于4.2.6 org.hibernate.Session
类中实际缺少的方法。此外,检查早期版本4.2.1,4.2.3等,但没有看到为Session类定义的任何 getSession()
方法。不确定该功能是否已被删除。任何人都可以协助什么是最新版本的hibernate支持 EntityMode.MAP
?
谢谢!
Pankaj,我认为hibernate以编程方式完全移除了实体模式的设置。唯一的方法是在配置文件中配置一个具有实体模式的单独会话工厂。
I am trying to use dynamic hibernate model, below is the code snippet to get the session.I have declared "hibernate.default_entity_mode
" as "dynamic_map
" in hibernate session factory config xml.
// Declared at class level
@Autowired
private SessionFactory sessionFactory;
//In specific java-method
Session pojoSession = sessionFactory.getCurrentSession();
Session ds = pojoSession.getSession(EntityMode.MAP);
Still, I get an exception in eclipse saying-"The method getSession(EntityMode) is undefined for the type Session
" on second line, while trying to get dynamicSession from pojoSession.
I am using Hibernate 4.2.6.Final core and entity-manager & spring 3.2 framework jars.
Can anyone assist on what I am doing wrong?
Update: Seems like that method is actually missing from 4.2.6 org.hibernate.Session
class. Also, checked earlier versions 4.2.1, 4.2.3 etc, but don't see any getSession()
method defined for Session class. Not sure if the feature has been removed. Can anyone assist on what is the latest version of hibernate supporting EntityMode.MAP
?
Thanks!
Pankaj, I think hibernate had complete removed setting of entity mode programmatically. The only way is to have a separate session factory with entity mode configured in configuration file.
这篇关于带有Hibernate 4.2.6 + Spring 3.2的EntityMode.Map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!