Package javax.persistence

Examples of javax.persistence.EntityManager


     * @param operationType the operation type.
     * @param description the operation description.
     */
    public void insertOperationLogger(final String className, final CallbackType event, final String eventClassName,
            final OperationType operationType, final String description) {
        EntityManager entityManager = entityManagerFactory.createEntityManager();

        OperationLogger logger = new OperationLogger();
        logger.setCallbackClassName(eventClassName);
        logger.setCallbackEvent(event);
        logger.setClassName(className);
        logger.setInsertionDate(getTime());
        logger.setOperationType(operationType);
        logger.setDescription(description);
        entityManager.persist(logger);
        entityManager.flush();
    }
View Full Code Here


        // Checks if the size of descriptions is the same as eventClassNames.
        assertTrue(descriptions.length == eventClassNames.length,
                "The length of descriptions and event class names must be equal.");

        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createQuery("SELECT e FROM OperationLogger "
                + "e WHERE e.className = :className AND e.callbackEvent= :event AND e.operationType = :operationType");
        query.setParameter("className", className);
        query.setParameter("event", event);
        query.setParameter("operationType", operationType);
        List callbackList = query.getResultList();
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

            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

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

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

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

     * 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

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

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

TOP

Related Classes of javax.persistence.EntityManager

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.