Package javax.persistence

Examples of javax.persistence.EntityManager.lock()


                    log.trace("Employee=" + employee);
                    Map<String, Object> lockProps = buildPropsMap(args, 3);
                    if (lockProps != null) {
                        em.lock(employee, lockMode, lockProps);
                    } else {
                        em.lock(employee, lockMode);
                    }
                    break;
                case LockObject:
                    em.lock(args[1], (LockModeType) args[2]);
                    break;
View Full Code Here


                    } else {
                        em.lock(employee, lockMode);
                    }
                    break;
                case LockObject:
                    em.lock(args[1], (LockModeType) args[2]);
                    break;
                case UpdateEmployee:
                    id = 1;
                    if (args.length > 1) {
                        id = (Integer) args[1];
View Full Code Here

                case Trace:
                    log.trace(args[1]);
                    break;

                case Test:
                    em.lock("xxx", LockModeType.WRITE);
                    break;
                default:
                }
            } catch (Exception ex) {
                // only remember the first exception caught
View Full Code Here

                    }
                    employee = employees.get(id);
                    log.trace("Employee=" + employee);
                    Map<String, Object> lockProps = buildPropsMap(args, 3);
                    if (lockProps != null) {
                        em.lock(employee, lockMode, lockProps);
                    } else {
                        em.lock(employee, lockMode);
                    }
                    break;
                case LockObject:
View Full Code Here

    try {
      tx.begin();
      org.apache.juddi.model.Subscription modelSubscription = em.find(org.apache.juddi.model.Subscription.class, resultList.getSubscription().getSubscriptionKey());
      log.debug("Taking out a write lock on this subscription, and bail if we can't get it since that would mean"
       + " another jUDDI instance is in the process of sending out the notification.");
      em.lock(modelSubscription, LockModeType.WRITE);
      Date startPoint = resultList.getCoveragePeriod().getStartPoint().toGregorianCalendar().getTime();
      Date endPoint   = resultList.getCoveragePeriod().getEndPoint().toGregorianCalendar().getTime();
      if (modelSubscription.getLastNotified()!=null
          && startPoint.before(modelSubscription.getLastNotified())
          && endPoint.after(modelSubscription.getLastNotified())) {
View Full Code Here

    }

    public void lock(Object o, LockModeType lockModeType) {
        EntityManager entityManager = getEntityManager(false);
        if (entityManager != null) {
             entityManager.lock(o, lockModeType);
        } else {
            entityManager = createEntityManager();
            try {
                 entityManager.lock(o, lockModeType);
            } finally {
View Full Code Here

        if (entityManager != null) {
             entityManager.lock(o, lockModeType);
        } else {
            entityManager = createEntityManager();
            try {
                 entityManager.lock(o, lockModeType);
            } finally {
                entityManager.close();
            }
        }
    }
View Full Code Here

    em.persist( lock );
    em.getTransaction().commit();

    em.getTransaction().begin();
    lock = em.getReference( Lock.class, lock.getId() );
    em.lock( lock, LockModeType.READ );
    lock.setName( "surname" );
    em.getTransaction().commit();

    em.getTransaction().begin();
    lock = em.find( Lock.class, lock.getId() );
View Full Code Here

    em.getTransaction().commit();

    em.getTransaction().begin();
    lock = em.getReference( Lock.class, lock.getId() );
    Integer version = lock.getVersion();
    em.lock( lock, LockModeType.WRITE );
    em.getTransaction().commit();

    em.getTransaction().begin();
    lock = em.getReference( Lock.class, lock.getId() );
    try {
View Full Code Here

    }
    catch (TransactionRequiredException e) {
      //success
    }
    try {
      em.lock( book, LockModeType.READ );
      fail( "lock has to be inside a Tx" );
    }
    catch (TransactionRequiredException e) {
      //success
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.