Hi All
I use the dynamic mappings and I don get the transaction working.
Accoring to the manual:
Session dynamicSession = pojoSession.getSession(EntityMode.MAP);
// Create a customer
Code:
Map david = new HashMap();
david.put("name", "David");
dynamicSession.save("Customer", david);
...
dynamicSession.flush();
dynamicSession.close()
...
// Continue on pojoSession
Please note that the call to getSession() using an EntityMode is on the Session API, not the SessionFactory. That way, the new Session shares the underlying JDBC connection, transaction, and other context information. This means you don't have tocall flush() and close() on the secondary Session, and also leave the transaction and connection handling to the primary unit of work.
This is what I do:
Code:
Session mapSession = sessionFactory.getCurrentSession().getSession(EntityMode.MAP);
mapSession.saveOrUpdate(metadataModelToSaveWith.getName(), metadataObject.getMetadata().getMap());
What Im saying here is that the primaty unit of work is NOT handling the flush since nothing gets saved. I use hibernate in a ASpring application running on JBoss.
Anyone had the same problem or has a solution?
Cheers
Magnus