Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionTemplate.execute()


        });

        assertTrue(TransactionSynchronizationManager.hasResource(factory));
        TransactionTemplate tt2 = new TransactionTemplate(transactionManager);
        tt2.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
        return tt2.execute(new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return template.execute(new JpaCallback() {
              public Object doInJpa(EntityManager em2) {
                em2.flush();
                return l;
View Full Code Here


  public void testReadExclusive() {
   
    TransactionTemplate transactionTemplate =
      new TransactionTemplate(transactionManager);
   
    transactionTemplate.execute(
        new TransactionCallback() {
          public Object doInTransaction(TransactionStatus ts) {
            Employee employee =  employeeDao.readExclusive(testEmployees.get(0).getId());
            AssertJUnit.assertNotNull("Employee for id=1 not read.", employee);
            return null;
View Full Code Here

   
  @Test (groups="createsObjectInDB")
    public void testStoreMultiple() {
        employeeDao.flushAndClear();
      TransactionTemplate xTemplate = new TransactionTemplate(transactionManager);
      xTemplate.execute(new TransactionCallback() {
   
      public Object doInTransaction(TransactionStatus arg0) {
            List<Employee> employees =Arrays.asList(
                new Employee[] {
                    new Employee("StoreMultipleOne", "Hightower"),
View Full Code Here

    return new String[] { "org/jencks/samples/outbound/jencks-genericjmsra.xml" };
  }

  protected void checkIfMessageExist(final String sentMessage) {
    TransactionTemplate tt = new TransactionTemplate(getTransactionManager());
    tt.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        JmsTemplate template=new JmsTemplate(getConnectionFactory());
        template.setReceiveTimeout(10);
        String receivedMessage=(String)template.receiveAndConvert(getQueue());
        assertEquals(sentMessage,receivedMessage);
View Full Code Here

    });
  }

  protected void checkIfMessageNotExist() {
    TransactionTemplate tt = new TransactionTemplate(getTransactionManager());
    tt.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        JmsTemplate template=new JmsTemplate(getConnectionFactory());
        template.setReceiveTimeout(10);
        String receivedMessage=null;
        receivedMessage=(String)template.receiveAndConvert(getQueue());
View Full Code Here

    // set behavior
    txTemplate.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
    final String noCommentSql[] = removeCommentsAndSemicolons(connectionModel.getSchema(), sql);
    try {
      // run the code in a transaction
      txTemplate.execute(new TransactionCallbackWithoutResult() {
        public void doInTransactionWithoutResult(TransactionStatus status) {
          jt.batchUpdate(noCommentSql);
        }
      });
    } catch (DataAccessException e) {
View Full Code Here

        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
View Full Code Here

        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
View Full Code Here

        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
View Full Code Here

        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
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.