質問

i have the following code in some thread runing, so far i can make it persist in the

        entityManager = DatabaseCommon.getEntityManager();

        entityManager.getTransaction().begin();
        entityManager.persist(smsReceived);
        entityManager.getTransaction().commit();

        sendedMo = sendMo(); //that method consumes a WS.

        if (sendedMo) {
            smsReceived.setSmsStatus("0");
        }

        entityManager.getTransaction().begin();
        entityManager.merge(smsReceived);
        entityManager.getTransaction().commit();

This is in a try catch blocks of course, so, the questions is: How to wait merge until a persist is made?

thx :)

役に立ちましたか?

解決

After you persist(), you commit the transaction. After committing successfully you are guaranteed that the persist operation was correct, so you are free to merge() further, as you do. So your code seems OK to me.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top