/** * Looks up the active UnitOfWork using either the global JTA TX or acquires * a new one from the active session. THis method should be used if a session * has already been acquired. */ public UnitOfWork acquireUnitOfWork(Session session) { if (session.hasExternalTransactionController()) { return session.getActiveUnitOfWork(); } return session.acquireUnitOfWork(); }
/** * Looks up the active UnitOfWork using either the global JTA TX or acquires * a new one from the active session. THis method should be used if a session * has already been acquired. */ public UnitOfWork acquireUnitOfWork(Session session) { if (session.hasExternalTransactionController()) { return session.getActiveUnitOfWork(); } return session.acquireUnitOfWork(); }
/** * Looks up the active UnitOfWork using either the global JTA TX or acquires * a new one from the active session. THis method should be used if a session * has already been acquired. */ public UnitOfWork acquireUnitOfWork(Session session) { if (session.hasExternalTransactionController()) { return session.getActiveUnitOfWork(); } return session.acquireUnitOfWork(); }
@Override public void preBeginTransaction(SessionEvent event) { try { UnitOfWork work = event.getSession().acquireUnitOfWork(); try { work.executeNonSelectingSQL("set names utf8mb4"); work.commit(); work = null; } finally { if (work != null) work.release(); } } catch (Exception ex) { log.error("UTF8MB4", ex); } } });
/** * Execute <tt>INSERT</tt> operation on the database * @param xrService parent <code>XRService</code> that owns this <code>Operation</code> * @param invocation contains runtime argument values to be bound to the list of * {@link Parameter}'s. * @return result - <code>null</code> as the underlying <tt>INSERT</tt> operation on * the database does not return a value. * * @see Operation */ @Override public Object invoke(XRServiceAdapter xrService, Invocation invocation) { Object instance = invocation.getParameters().toArray()[0]; UnitOfWork uow = xrService.getORSession().acquireUnitOfWork(); uow.registerNewObject(instance); uow.commit(); return null; } }
/** * Execute <tt>INSERT</tt> operation on the database * @param xrService parent <code>XRService</code> that owns this <code>Operation</code> * @param invocation contains runtime argument values to be bound to the list of * {@link Parameter}'s. * @return result - <code>null</code> as the underlying <tt>INSERT</tt> operation on * the database does not return a value. * * @see {@link Operation} */ @Override public Object invoke(XRServiceAdapter xrService, Invocation invocation) { Object instance = invocation.getParameters().toArray()[0]; UnitOfWork uow = xrService.getORSession().acquireUnitOfWork(); uow.registerNewObject(instance); uow.commit(); return null; } }
UnitOfWork uow = xrService.getORSession().acquireUnitOfWork(); Object toBeDeleted;
UnitOfWork uow = xrService.getORSession().acquireUnitOfWork(); Object toBeDeleted;
public Object invoke(XRServiceAdapter xrService, Invocation invocation) { XRDynamicEntity instance = (XRDynamicEntity)invocation.getParameters().toArray()[0]; UnitOfWork uow = xrService.getORSession().acquireUnitOfWork(); ReadObjectQuery query = new ReadObjectQuery(); query.setSelectionObject(instance);
public Object invoke(XRServiceAdapter xrService, Invocation invocation) { XRDynamicEntity instance = (XRDynamicEntity)invocation.getParameters().toArray()[0]; UnitOfWork uow = xrService.getORSession().acquireUnitOfWork(); ReadObjectQuery query = new ReadObjectQuery(); query.setSelectionObject(instance);