Impossible to switch session to EntityMode.MAP

Description

According to the latest version of documentation http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#persistent-classes-dynamicmodels it should be possible to switch from POJO EntityMode to MAP.
Session dynamicSession = pojoSession.getSession(EntityMode.MAP);
"Please note that the call to getSession() using an EntityMode is on the Session API, not the SessionFactory."
but the Session API doesn't have the method getSession(...), so it's impossible to switch to the map mode. The one possibility is to set hibernate.default_entity_mode to dynamic-map in the configuration. But it will change the affects to all sessions.
I'm not sure if this is a documentation problem or missing feature.

Environment

None

Activity

Show:
Adrian Corcoran
September 22, 2014, 3:51 PM

I just came across this bug as I was unable to find the implement of 'pojoSession.getSession(EntityMode.MAP);'

To my mind this is a bug - without this functionality I don't see how an application can store user defined fields i.e. in the case that an application is dealing mainly with well defined pojos but allows for some tables to be customized on deployment.

Is there another API to cater for this as from my reading of the documentation this appears to the the intent of dynamic mapped entities.

Andreas Schiestl
August 14, 2015, 5:52 AM
Edited

I think also this is a bug. As Lukasz Antoniak pointed out is is possible to create a seperate session factory, but this is not the solution for every problem. If you need to modify an MAP and POJO entity within the same transaction, this workaround does not work.

Bob BitDiddle
February 5, 2016, 2:04 AM

Can someone add this feature back, please? I can't recommend our customers migrate to Hibernate 4 in the current situation since existing code is going to break. In our situation we manage the Hibernate session factory for the customer, so having to create a separate session factory is not going to be possible.

BartłomiejB
February 5, 2016, 6:17 AM

Yep, the feature was very useful, because it allowed you to mix statically typed code with dynamic map in one session.

Vlad Mihalcea
October 5, 2016, 1:20 PM

The Hibernate 4.x documentation is misleading. However, it is no longer maintained, and the Hibernate 5.x documentation which was rewritten from scratch no longer shows any Hibernate 3.x example.

Assignee

Unassigned

Reporter

BartłomiejB

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major
Configure