Examples of TransactionStatus


Examples of org.springframework.transaction.TransactionStatus

  public void registerTransactionManager(TransactionDefinition definition, PlatformTransactionManager transactionManager) {
    getTransactionStatuses().put(transactionManager, transactionManager.getTransaction(definition));
  }

  public void commit(PlatformTransactionManager transactionManager) {
    TransactionStatus transactionStatus = getTransactionStatus(transactionManager);
    transactionManager.commit(transactionStatus);
  }
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

   
    public void testSaveWithCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Id null before adding:
        assertNull(emp.getId());
        // Save:
        this.template.save(emp);
        // Id not null after adding:
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

   
    public void testDoubleCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save:
        this.template.save(emp);
        // Commit the transaction status:
        this.transactionManager.commit(status);
        // The double commit fails:
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

   
    public void testSaveWithTimeout() throws InterruptedException {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp);
        // Go to sleep, waiting for timeout:
        Thread.sleep(2000);
        // Trying to commit will failbecause the transaction has been aborted due to the timeout:
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

   
    public void testSaveWithRollback() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp);
        // Verify that the employee has been saved in the current transaction scope:
        EmployeeImpl emp2 = (EmployeeImpl) this.template.get(Employee.class, emp.getId());
        assertNotNull(emp);
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

        EmployeeImpl emp2 = new EmployeeImpl("a2");
        Long id1 = null;
        Long id2 = null;
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp1);
        // Rollback
        this.transactionManager.rollback(status);
       
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

        EmployeeImpl emp2 = new EmployeeImpl("a2");
        Long id1 = null;
        Long id2 = null;
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp1);
        // Rollback
        this.transactionManager.commit(status);
       
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

   
    public void testConcurrency() throws InterruptedException {
        Runnable r1 = new Runnable() {
            public void run() {
                EmployeeImpl emp1 = new EmployeeImpl("a1");
                TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
                template.save(emp1);
                transactionManager.commit(status);
               
                EmployeeImpl emp2 = (EmployeeImpl) template.get(EmployeeImpl.class, emp1.getId());
               
                assertNotNull(emp2);
                assertEquals("First: " + emp1.getMatriculationCode() + " - Second: "+ emp2.getMatriculationCode(), emp1, emp2);
            }
        };
       
        Runnable r2 = new Runnable() {
            public void run() {
                EmployeeImpl emp1 = new EmployeeImpl("a2");
                TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
                template.save(emp1);
                transactionManager.commit(status);
               
                EmployeeImpl emp2 = (EmployeeImpl) template.get(EmployeeImpl.class, emp1.getId());
               
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

            //need to propagate any exceptions back to Spring container
            //so transactions can occur
            if (inMessage.getContent(Exception.class) != null && session != null) {
                PlatformTransactionManager m = jmsConfig.getTransactionManager();
                if (m != null) {
                    TransactionStatus status = m.getTransaction(null);
                    JmsResourceHolder resourceHolder =
                        (JmsResourceHolder) TransactionSynchronizationManager
                            .getResource(jmsConfig.getConnectionFactory());
                    boolean trans = resourceHolder == null
                        || !resourceHolder.containsSession(session);
                    if (status != null && !status.isCompleted() && trans) {
                        Exception ex = inMessage.getContent(Exception.class);
                        if (ex.getCause() instanceof RuntimeException) {
                            throw (RuntimeException)ex.getCause();
                        } else {
                            throw new RuntimeException(ex);
View Full Code Here

Examples of org.springframework.transaction.TransactionStatus

            //need to propagate any exceptions back to Spring container
            //so transactions can occur
            if (inMessage.getContent(Exception.class) != null && session != null) {
                PlatformTransactionManager m = jmsConfig.getTransactionManager();
                if (m != null) {
                    TransactionStatus status = m.getTransaction(null);
                    JmsResourceHolder resourceHolder =
                        (JmsResourceHolder) TransactionSynchronizationManager
                            .getResource(jmsConfig.getConnectionFactory());
                    boolean trans = resourceHolder == null
                        || !resourceHolder.containsSession(session);
                    if (status != null && !status.isCompleted() && trans) {
                        Exception ex = inMessage.getContent(Exception.class);
                        if (ex.getCause() instanceof RuntimeException) {
                            throw (RuntimeException)ex.getCause();
                        } else {
                            throw new RuntimeException(ex);
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.