Examples of EntityManager


Examples of javax.persistence.EntityManager

            logger.debug("Callback: {0}", arAll.get(i).toString());
        }

        logger.debug("Finding: className={0}, callbackEvent={1}", className, callbackEvent);

        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createNamedQuery("findLifecycleEvent");
        query.setParameter("className", className);
        query.setParameter("event", callbackEvent);


        List arFound = query.getResultList();
View Full Code Here

Examples of javax.persistence.EntityManager

     * @return the list of results.
     */
    public List findCallbackEvent(final String className) {
        logger.debug("Finding: className={0}", className);

        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createNamedQuery("findLifecycleEventByClass");
        query.setParameter("className", className);
        return query.getResultList();
    }
View Full Code Here

Examples of javax.persistence.EntityManager

     * @param callbackClassName the class taht the callback method is defined.
     * @return the list of results.
     */
    public List findCallbackEventByCallbackMethod(final String className, final CallbackType callbackEvent,
            final String callbackClassName) {
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createNamedQuery("findLifecycleEventByCallbackMethod");
        query.setParameter("className", className);
        query.setParameter("event", callbackEvent);
        query.setParameter("callbackClassName", callbackClassName);
        return query.getResultList();
    }
View Full Code Here

Examples of javax.persistence.EntityManager

    /**
     * Finds all callback events.
     * @return events
     */
    public List findAll(){
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createNamedQuery("findAll");
        return query.getResultList();
    }
View Full Code Here

Examples of javax.persistence.EntityManager

     * Deletes all callback events from the database.
     */
    @ExcludeDefaultInterceptors
    @ExcludeClassInterceptors
    public void deleteAll() {
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createNamedQuery("findAll");
        List lstEvent = query.getResultList();
        for (Object obj : lstEvent) {
            CallbackLogger callbackLogger = (CallbackLogger) obj;
            if (callbackLogger != null) {
                entityManager.remove(callbackLogger);
            }
        }
    }
View Full Code Here

Examples of javax.persistence.EntityManager

     */
    public static void checkEntityManager(final EJBContext ejbContext, final String pUnitName) {
        logger.debug("Checking Entity Manager. Name = {0}", pUnitName);

        // Session Context
        EntityManager sctxEntry = getEntryByEJBContext(ejbContext, pUnitName);
        checkEntityManager(sctxEntry);

        // JNDI Access
        EntityManager eJNDI = getEntryByJNDI(pUnitName);
        checkEntityManager(eJNDI);

        logger.debug("Entity Manager is ok. Name = {0}", pUnitName);
    }
View Full Code Here

Examples of javax.persistence.EntityManager

     * @param callbackClassName the name of the class that contains the callback
     *        method.
     */
    public void insertCallbackLogger(final String className,
            final CallbackType callbackEvent, final String callbackClassName) {
        EntityManager entityManager = entityManagerFactory.createEntityManager();

        CallbackLogger logger = new CallbackLogger();
        logger.setCallbackClassName(callbackClassName);
        logger.setCallbackEvent(callbackEvent);
        logger.setClassName(className);
        logger.setInsertionDate(getTime());
        entityManager.persist(logger);
        entityManager.flush();
    }
View Full Code Here

Examples of javax.persistence.EntityManager

                logger.debug("Error in EntityManagerFactory use: {0}", e);
                e.printStackTrace();
            }

        } else if (isEqual(ENTITY_MANAGER, op)) {
            EntityManager em = (EntityManager) ctx.lookup("persistence/pctx01");
            try {
                EntityManagerTester.checkInstance(em, "tmpTable" + this.hashCode());
                log(MDBListenerMethodAccess.class, ON_MESSAGE, MDBListenerMethodAccess.class, ENTITY_MANAGER);
            } catch (Exception e) {
                logger.debug("Error in EntityManagerFactory use: {0}", e);
View Full Code Here

Examples of javax.persistence.EntityManager

    /**
     * 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

Examples of javax.persistence.EntityManager

    /**
     * Verifies if the rollback works.
     */
    public void resourceLevelRollback() {
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        // begins the transaction
        entityManager.getTransaction().begin();
        // creates a book
        Book book = new Book();
        book.setId(ID);
        book.setName(ENTITY_NAME);
        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");
    }
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.