andyrus wrote:
Transaction helper used to be in org.hibernate.engine.TransactionHelper
the method required is doWorkinNewTransaction
This concept is now handled non-statically by org.hibernate.engine.transaction.spi.IsolationDelegate which is varied for you based on the underlying transaction mechanism. ATM I do not expose this via any of the APIs, it is however accessible via SPIs:
Code:
org.hibernate.spi.SessionImplementor sessionSpi = (org.hibernate.spi.SessionImplementor) session;
sessionSpi.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
new org.hibernate.jdbc.AbstractWork() {
@Override
public void execute(Connection connection) throws SQLException {
// do your work here, knowing you are in a new transaction
}
},
true
);
There is also a form of Work returning a value, ReturningWork:
Code:
org.hibernate.spi.SessionImplementor sessionSpi = (org.hibernate.spi.SessionImplementor) session;
Integer someValue = sessionSpi.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
new org.hibernate.jdbc.AbstractReturningWork<Integer>() {
@Override
public Integer execute(Connection connection) throws SQLException {
// do your work here, knowing you are in a new transaction
return someIntegerValue;
}
},
true
);
andyrus wrote:
getSession() is a method used in 3... which I also believe was in hibernate.engine but now has dissappeared.
line of code is
Session session = this.getCurrentSession().getSession(EntityMode.MAP);
The ability to mix entitymodes *for an entity* within a Session/SessionFactory is removed. Within a SessionFactory an entity is either POJO or MAP.