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.
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.
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.
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.
Yep, the feature was very useful, because it allowed you to mix statically typed code with dynamic map in one session.
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.