@Override public Object set(final int arg0, final Object arg1) { eagerlyLoadDataCollection(); List dataList = (List) dataCollection; Object result = null; if (dataList != null && !dataList.isEmpty()) { if (dataList.get(arg0) == null) { getPersistenceDelegator().persist(arg1); result = dataList.set(arg0, arg1); } else { getPersistenceDelegator().merge(arg1); result = dataList.set(arg0, arg1); } } return result; }
private void applyOperations(PersistenceDelegator pd, OToOOwnerEntity found, AssociationEntity association, boolean remove) { found.setAssociation(association); pd.merge(found); pd.doFlush(); pd.detach(association); pd.merge(found); // detach over association entity should work. if (remove) pd.remove(found); // since we have called merge, so association // entity should be in MANAGED_STATE and cascade // should work. } }
/** * Merge the state of the given entity into the current persistence context. * * @param entity * @return the managed instance that the state was merged to * @throws IllegalArgumentException * if instance is not an entity or is a removed entity * @throws TransactionRequiredException * if invoked on a container-managed entity manager of type * PersistenceContextType.TRANSACTION and there is no * transaction * @see javax.persistence.EntityManager#merge(java.lang.Object) */ @Override public final <E> E merge(E e) { checkClosed(); checkTransactionNeeded(); try { return getPersistenceDelegator().merge(e); } catch (Exception ex) { // on Rollback doRollback(); throw new KunderaException(ex); } }
persistenceDelegeator.merge(result);