Sun River
          Topics about Java SE, Servlet/JSP, JDBC, MultiThread, UML, Design Pattern, CSS, JavaScript, Maven, JBoss, Tomcat, ...
          posts - 78,comments - 0,trackbacks - 0
           

          1. How someone can define that a method should be execute inside read-only transaction semantics?

            A

          It is not possible

            B

          No special action should be taken, default transaction semantics is read-only

            C

          It is possible using the following snippet:
          <tx:methodname="some-method"semantics="read-only"/>

          D

          It is possible using the following snippet:
          <tx:methodname="some-method"read-only="true"/>  

          explanation

          Default semantics in Spring is read/write, and someone should use read-only attribute to define read-only semantics for the method.

          2.      What is the correct way to execute some code inside transaction using programmatic transaction management?

           A

          Extend TransactionTemplate class and put all the code inside execute() method.

            B

          Implement class containing business code inside the method. Inject this class into TransactionManager.

          C

          Extend TransactionCallback class. Put all the code inside doInTransaction() method. Pass the object of created class as parameter to transactionTemplate.execute() method. 

            D

          Extend TransactionCallback class. Put all the code inside doInTransaction() method. Create the instance of TransactionCallback, call transactionCallback.doInTransaction method and pass TransactionManager as a parameter.

          3. Select all statements that are correct.

          Spring provides a consistent programming model across different transaction APIs such as JTA, JDBC, Hibernate, JPA, and JDO.

          The Spring Framework supports declarative transaction management.

          Spring provides a simpler API for programmatic transaction management than a number of complex transaction APIs such as JTA.

          The transaction management integrates very well with Spring's various data access abstractions.

          4. Does this method guarantee that all of its invocations will process data with ISOLATION_SERIALIZABLE?
          Assume
          txManager to be valid and only existing PlatformTransactionManager .
          publicvoid query(){
                 DefaultTransactionDefinition txDef =newDefaultTransactionDefinition();
                 txDef.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
                 txDef.setReadOnly(true);
                 txDef.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
                 TransactionStatus txStat = txManager.getTransaction(txDef);
                 // ...
                 txManager.commit(txStat);
          }

          explanation

          If this method executes within an existing transaction context, it's isolation level will reflect the existing isolation level. For example JDBC does not specify what happens when one tries to change isolation level during existing transaction. PROPAGATION_REQUIRES_NEW will assure that transaction isolation is set to serializable.

          5. You would like to implement class with programmatic transaction management.
          How can you get TransactionTemplate instance?

          It is necessary to implement a certain interface in this class and then use getTransactionTemplate() call.

           

          It is possible to declare TransactionTemplate object in configuration file and inject it in this class.

          It is possible to declare PlatformTransactionManager object in configuration file, inject the manager in this class and then create TransactionTemplate like
          TransactionTemplate transactionTemplate =newTransactionTemplate(platformTransactionManager);

          It's possible to inject either PlatformTransactionManager or TransactionTemplate in this class.
          Option one is obviously wrong.

          6. Check the correct default values for the @Transactional annotation.

          PROPAGATION_REQUIRED

          The isolation level defaults to the default level of the underlying transaction system.

          readOnly="true"

           

          Only the Runtime Exceptions will trigger rollback.

          The transaction timeout defaults to the default timeout of the underlying transaction system, or none if timeouts are not supported.

          7. To make a method transactional in a concrete class it's enough to use @Transactional annotation before the method name (in Java >=5.0).

          correct answer

          FALSE

          explanation

          No, @Transactional annotation only marks a method as transactional. To make it transactional it is necessary to include the <tx:annotation-driven/> element in XML configuration file.

          8. The JtaTransactionManager allows us to use distributed transactions. (t)
          posted on 2007-12-01 15:20 Sun River 閱讀(862) 評論(0)  編輯  收藏 所屬分類: Spring
          主站蜘蛛池模板: 固始县| 永定县| 宿州市| 华宁县| 双江| 始兴县| 东乌珠穆沁旗| 监利县| 隆德县| 垣曲县| 濉溪县| 乐业县| 宁晋县| 玉环县| 西乌| 罗山县| 简阳市| 白水县| 望都县| 庆元县| 稷山县| 陈巴尔虎旗| 丰顺县| 临湘市| 广汉市| 兴安县| 浮梁县| 大庆市| 清苑县| 汉阴县| 蒙阴县| 会昌县| 金寨县| 承德市| 北川| 瑞安市| 永登县| 磐安县| 武鸣县| 永靖县| 益阳市|