Package javax.persistence

Examples of javax.persistence.EntityManager.joinTransaction()


        transactionTemplate.execute(new TransactionCallback<Object>() {
            public Object doInTransaction(TransactionStatus status) {
                // make use of the EntityManager having the relevant persistence-context
                EntityManager entityManager2 = receivedExchange.getIn().getHeader(JpaConstants.ENTITYMANAGER, EntityManager.class);
                entityManager2.joinTransaction();

                // now lets assert that there are still 2 entities left
                List<?> rows = entityManager2.createQuery("select x from MultiSteps x").getResultList();
                assertEquals("Number of entities: " + rows, 2, rows.size());
View Full Code Here


        // Initialized persistence/tx's and persist to db
        EntityManager em = emf.createEntityManager();
        em.setFlushMode(FlushModeType.COMMIT);
        UserTransaction tx = findUserTransaction();
        tx.begin();
        em.joinTransaction();
        em.persist(badMainObject);
       
        boolean rollBackExceptionthrown = false;
        try {
            logger.info("The following " + IllegalStateException.class.getSimpleName() + " SHOULD be thrown.");
View Full Code Here

        mainObject.setName("main" + testName);
        mainObject.setSubObject(subObject);
       
        // Now persist both..
        tx.begin();
        em.joinTransaction();
        em.persist(mainObject);
        em.persist(subObject);
       
        try {
            tx.commit();
View Full Code Here

        // Run this in single transaction.
        Boolean rc = transactionTemplate.execute(new TransactionCallback<Boolean>() {
            public Boolean doInTransaction(TransactionStatus status) {
                if (isJoinTransaction()) {
                    entityManager.joinTransaction();
                }

                List<?> list = query(entityManager, messageId);
                if (list.isEmpty()) {
                    MessageProcessed processed = new MessageProcessed();
View Full Code Here

        // Run this in single transaction.
        Boolean rc = transactionTemplate.execute(new TransactionCallback<Boolean>() {
            public Boolean doInTransaction(TransactionStatus status) {
                if (isJoinTransaction()) {
                    entityManager.joinTransaction();
                }

                List<?> list = query(entityManager, messageId);
                if (list.isEmpty()) {
                    return Boolean.FALSE;
View Full Code Here

        final EntityManager entityManager = getTargetEntityManager(exchange, entityManagerFactory, true);

        Boolean rc = transactionTemplate.execute(new TransactionCallback<Boolean>() {
            public Boolean doInTransaction(TransactionStatus status) {
                if (isJoinTransaction()) {
                    entityManager.joinTransaction();
                }

                List<?> list = query(entityManager, messageId);
                if (list.isEmpty()) {
                    return Boolean.FALSE;
View Full Code Here

            final EntityManager entityManager = getTargetEntityManager(exchange, entityManagerFactory, getEndpoint().isUsePassedInEntityManager());

            transactionTemplate.execute(new TransactionCallback<Object>() {
                public Object doInTransaction(TransactionStatus status) {
                    if (getEndpoint().isJoinTransaction()) {
                        entityManager.joinTransaction();
                    }

                    if (values.getClass().isArray()) {
                        Object[] array = (Object[])values;
                        for (Object element : array) {
View Full Code Here

        Patient ourGuy;
        EntityManager em = null;
        try {
            em = emf.createEntityManager();
            utx.begin();
            em.joinTransaction();
            Query query = em.createQuery("SELECT p FROM Patient p WHERE p.ssn = :ssn");
            query.setParameter("ssn", ssn);
            try {
                ourGuy = (Patient)query.getSingleResult();
            } catch (NoResultException nre) {
View Full Code Here

        String result = null;
        EntityManager em = null;
        try {
            em = emf.createEntityManager();
            utx.begin();
            em.joinTransaction();
            ourGuy = em.find(Patient.class, patientid);
            if(ourGuy != null) {
                result = ourGuy.getFirstname();
            }
            utx.commit();
View Full Code Here

        String result = null;
        EntityManager em = null;
        try {
            em = emf.createEntityManager();
            utx.begin();
            em.joinTransaction();
            ourGuy = em.find(Patient.class, patientid);
            if(ourGuy != null) {
                result = ourGuy.getSurname();
            }
            utx.commit();
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.