public void test() {
    Server server = this.getServerSession();
    UnitOfWork uow = server.acquireUnitOfWork();
    ConcurrentLargeProject clonedProject = (ConcurrentLargeProject) uow.registerObject(project);
    clonedProject.getLocation().setPostalCode("K1P 1A4");
    ConcurrentPerson clonedPerson = (ConcurrentPerson) uow.registerObject(person);
    clonedPerson.setHobby(clonedProject);
    uow.writeChanges();

    Thread thread1 = new Thread(new ProjectReader(server.acquireClientSession(), project.getId()));
    ConcurrentProject.RUNNING_TEST = ConcurrentProject.READ_WITH_UOW_LOCKS_TESTS;
    // start reading Project, and have the thread wait while building DTF mappings
    thread1.start();

    try {
      thread1.join(
          1000); // wait a token amount to be sure that thread1 isn't starved before getting
                 // deferred lock on Project.
    } catch (InterruptedException ex) {
    }

    // start uow commit, which will get locks on Person+Address, commit, then merge.
    // merge should get a deferred lock on Project.
    Thread thread2 = new Thread(new UOWCommit(uow));
    thread2.start();

    // while waiting, thread1 should wake and try to get a lock on Address.  It will deadlock if it
    // tries to get an active lock, since they will be held by the UOW which can't complete until
    // thread1
    // releases.
    try {
      thread1.join(20000);
      if (thread1.isAlive()) {
        try {
          thread1.interrupt();
          thread2.interrupt();
        } catch (Exception e) {
        }
        deadlockDetected = true;
      }
    } catch (InterruptedException ex) {
    }
  }
 public void test() {
   UnitOfWork uow = getSession().acquireUnitOfWork();
   uow.writeChanges();
   uow.commitAndResume();
 }