Results 1 to 8 of 8

Thread: Query.executeUpdate() - No transaction is currently active

Threaded View

  1. #1
    Join Date
    Jan 2011
    Posts
    5

    Default [SOLVED] - Query.executeUpdate() - No transaction is currently active

    Hi,
    I'm having trouble using the method executeUpdate (). An example:
    Code:
    public void update() {
    		DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    		
    		def.setName("updateTx");
    		def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    		
    		TransactionStatus status = txManager.getTransaction(def);
    		Query query = entityManager.createQuery(" update Contact c set c.name = 'Daniel' where c.id = '2'");
    		query.executeUpdate();
    		
    		txManager.commit(status);
    }
    This code ever throw an Exception:
    Code:
    javax.persistence.TransactionRequiredException: 
    Exception Description: No transaction is currently active
    Any idea what might be happening?
    Last edited by d.frank; Feb 1st, 2011 at 10:45 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •