Package javax.persistence

Examples of javax.persistence.EntityManager.find()


       
        // First compile the associated document, we assume this returns a single structure
        // That can be used in the main work item evaluation.
        Content content = null;
        if ( taskData.getDocumentAccessType() == AccessType.Inline ) {
            content = em.find( Content.class,
                               taskData.getDocumentContentId() );
        }
        ExpressionCompiler compiler = new ExpressionCompiler( new String( content.getContent() ) );
        Serializable expr = compiler.compile();
        Object object = MVEL.executeExpression( expr );
View Full Code Here


    }

    public void executeEscalatedDeadline(long taskId,
                                         long deadlineId) {
        EntityManager localEm = emf.createEntityManager();
        Task task = localEm.find(Task.class,
                taskId);
        Deadline deadline = localEm.find(Deadline.class,
                deadlineId);

        if (escalatedDeadlineHandler == null) {
View Full Code Here

    public void executeEscalatedDeadline(long taskId,
                                         long deadlineId) {
        EntityManager localEm = emf.createEntityManager();
        Task task = localEm.find(Task.class,
                taskId);
        Deadline deadline = localEm.find(Deadline.class,
                deadlineId);

        if (escalatedDeadlineHandler == null) {
            escalatedDeadlineHandler = new DefaultEscalatedDeadlineHandler();
        }
View Full Code Here

      if (clazz.equals(Named.class)) {
        named = (Named) a;
      }
    }
    if (named == null)
      return em.find(getMethodReturnType(), parameters[0]);
    else {
      String ejbql = "from " + getMethodReturnType().getSimpleName() + " entity where entity." + named.value()
              + "=?";
      Query query = em.createQuery(ejbql);
      query.setParameter(1, parameters[0]);
View Full Code Here

     * Deletes a callback event from the database.
     * @param id the callback identifier.
     */
    public void deleteCallbackEvent(final int id) {
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        CallbackLogger callbackLogger = entityManager.find(CallbackLogger.class, new Integer(id));
        if (callbackLogger != null) {
            entityManager.remove(callbackLogger);
        }
    }

View Full Code Here

    /**
     * Cleans the db.
     */
    public void startup() {
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        if (bookResult != null) {
            entityManager.remove(bookResult);
        }
    }

View Full Code Here

        entityManager.persist(book);
        // makes a rollback
        entityManager.getTransaction().rollback();
        entityManager.close();
        // verifies if the container made the rollback
        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        assertNull(bookResult, "The container did not make the rollback");
    }

    /**
     * Verifies if the serRollbackOnly works.
View Full Code Here

            logger.info("The bean threw an expected exception");
        }
        entityManager.close();

        // verifies if the transaction was rolled back
        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        assertNull(bookResult, "The container did not make the rollback");
    }

    /**
     * Verifies if the commit works.
View Full Code Here

                "The transaction is not marked as rollback, but the container returned true for the method getRollbackOnly()");
        // makes a commit
        entityManager.getTransaction().commit();
        entityManager.close();
        // verifies if the bean is persistent.
        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        assertNotNull(bookResult, "The container did not make the rollback");

    }
}
View Full Code Here

    public ResourceLevelTransTester() {
        // gets the EntitymanagerFactory for the persistence unite book
        entityManagerFactory = Persistence.createEntityManagerFactory("book");
        EntityManager entityManager = entityManagerFactory.createEntityManager();

        Book bookResult = entityManager.find(Book.class, new Integer(ID));
        if (bookResult != null) {
            entityManager.remove(bookResult);
        }
    }
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.