Package org.eclipse.persistence.sessions

Examples of org.eclipse.persistence.sessions.UnitOfWork


     * @see  {@link Operation}
     */
    @Override
    public Object invoke(XRServiceAdapter xrService, Invocation invocation) {
        Object instance = invocation.getParameters().toArray()[0];
        UnitOfWork uow = xrService.getORSession().acquireUnitOfWork();
        // read the existing object into the uow
        uow.readObject(instance);
        // overwrite it
        uow.mergeClone(instance);
        uow.commit();
        return null;
    }
View Full Code Here


     * @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;
    }
View Full Code Here

     * @see  {@link Operation}
     */
    @Override
    public Object invoke(XRServiceAdapter xrService, Invocation invocation) {
        Object clone = invocation.getParameters().toArray()[0];
        UnitOfWork uow = xrService.getORSession().acquireUnitOfWork();
        Object instance = uow.readObject(clone);
        uow.deleteObject(instance);
        uow.commit();
        return null;
    }
View Full Code Here

     * @throws PersistenceException if an unsupported lock call is made
     */
    public void refresh(Object entity, LockModeType lockMode, Map properties) {
        try {
            verifyOpen();
            UnitOfWork uow = getActivePersistenceContext(checkForTransaction(false));
            if (! contains(entity, uow)) {
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[] { entity }));
            }

            // Get the read object query and apply the properties to it.       
View Full Code Here

     *   cannot be accessed.
     */
    public <T> T getReference(Class<T> entityClass, Object primaryKey) {
        try {
            verifyOpen();
            UnitOfWork session = (UnitOfWork)getActiveSession();           
            Object reference = session.getReference(entityClass, primaryKey);
            if (reference == null) {
                Object[] args = {primaryKey};
                String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", args);
                throw new javax.persistence.EntityNotFoundException(message);
            }
View Full Code Here

    super.beginTransaction(entityManager, definition);
    if (!definition.isReadOnly() && !this.lazyDatabaseTransaction) {
      // This is the magic bit. As with the existing Spring TopLink integration,
      // begin an early transaction to force EclipseLink to get a JDBC Connection
      // so that Spring can manage transactions with JDBC as well as EclipseLink.
      UnitOfWork uow = (UnitOfWork) getSession(entityManager);
      uow.beginEarlyTransaction();
    }
    // Could return the UOW, if there were any advantage in having it later.
    return null;
  }
View Full Code Here

    super.beginTransaction(entityManager, definition);
    if (!definition.isReadOnly() && !this.lazyDatabaseTransaction) {
      // This is the magic bit. As with the existing Spring TopLink integration,
      // begin an early transaction to force EclipseLink to get a JDBC Connection
      // so that Spring can manage transactions with JDBC as well as EclipseLink.
      UnitOfWork uow = (UnitOfWork) getSession(entityManager);
      uow.beginEarlyTransaction();
    }
    // Could return the UOW, if there were any advantage in having it later.
    return null;
  }
View Full Code Here

     * @param entity instance registered in the current persistence context.
     */
    public void refresh(Object entity) {
        try {
            verifyOpen();
            UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended()));
            if (!contains(entity, uow)) {
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[] { entity }));
            }
            ReadObjectQuery query = new ReadObjectQuery();
            query.setSelectionObject(entity);
            query.refreshIdentityMapResult();
            query.cascadeByMapping();
            query.setLockMode(ObjectBuildingQuery.NO_LOCK);
            query.setIsExecutionClone(true);
            Object refreshedEntity = null;
            refreshedEntity = uow.executeQuery(query);
            if (refreshedEntity == null) {
                // bug5955326, ReadObjectQuery will now ensure the object is invalidated if refresh returns null.
                throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[] { entity }));
            }
        } catch (RuntimeException exception) {
View Full Code Here

     *   cannot be accessed.
     */
    public <T> T getReference(Class<T> entityClass, Object primaryKey) {
        try {
            verifyOpen();
            UnitOfWork session = (UnitOfWork)getActiveSession();           
            Object reference = session.getReference(entityClass, primaryKey);
            if (reference == null) {
                Object[] args = {primaryKey};
                String message = ExceptionLocalization.buildMessage("no_entities_retrieved_for_get_reference", args);
                throw new javax.persistence.EntityNotFoundException(message);
            }
View Full Code Here

        Vector executeArguments = new NonSynchronizedVector();
        for (int i = 0; i < queryArgumentsSize; i++) {
            String argName = (String)queryArguments.get(i);
            executeArguments.add(invocation.getParameter(argName));
        }
        UnitOfWork uow = xrService.getORSession().acquireUnitOfWork();
        Object toBeDeleted = uow.executeQuery(roq, executeArguments);
        if (toBeDeleted != null) {
            uow.deleteObject(toBeDeleted);
            uow.commit();
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.sessions.UnitOfWork

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.