/mycila-jdbc/tags/mycila-jdbc-1.5.rc1/src/main/java/com/mycila/jdbc/tx/Propagation.java

http://mycila.googlecode.com/ · Java · 90 lines · 10 code · 10 blank · 70 comment · 0 complexity · 2a80f70e515e8704bf5a9d3adb077b4f MD5 · raw file

  1. /**
  2. * Copyright (C) 2010 Mycila <mathieu.carbou@gmail.com>
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.mycila.jdbc.tx;
  17. /**
  18. * Enumeration that represents transaction propagation behaviors for use
  19. * with the {@link Transactional} annotation
  20. *
  21. * @author Colin Sampaleanu
  22. * @author Juergen Hoeller
  23. * @since 1.2
  24. */
  25. public enum Propagation {
  26. /**
  27. * Support a current transaction, create a new one if none exists.
  28. * Analogous to EJB transaction attribute of the same name.
  29. * <p>This is the default setting of a transaction annotation.
  30. */
  31. REQUIRED,
  32. /**
  33. * Support a current transaction, execute non-transactionally if none exists.
  34. * Analogous to EJB transaction attribute of the same name.
  35. * <p>Note: For transaction managers with transaction synchronization,
  36. * PROPAGATION_SUPPORTS is slightly different from no transaction at all,
  37. * as it defines a transaction scope that synchronization will apply for.
  38. * As a consequence, the same resources (JDBC Connection, Hibernate Session, etc)
  39. * will be shared for the entire specified scope. Note that this depends on
  40. * the actual synchronization configuration of the transaction manager.
  41. */
  42. SUPPORTS,
  43. /**
  44. * Support a current transaction, throw an exception if none exists.
  45. * Analogous to EJB transaction attribute of the same name.
  46. */
  47. MANDATORY,
  48. /**
  49. * Create a new transaction, suspend the current transaction if one exists.
  50. * Analogous to EJB transaction attribute of the same name.
  51. * <p>Note: Actual transaction suspension will not work on out-of-the-box
  52. * on all transaction managers. This in particular applies to JtaTransactionManager,
  53. * which requires the <code>javax.transaction.TransactionManager</code> to be
  54. * made available it to it (which is server-specific in standard J2EE).
  55. */
  56. REQUIRES_NEW,
  57. /**
  58. * Execute non-transactionally, suspend the current transaction if one exists.
  59. * Analogous to EJB transaction attribute of the same name.
  60. * <p>Note: Actual transaction suspension will not work on out-of-the-box
  61. * on all transaction managers. This in particular applies to JtaTransactionManager,
  62. * which requires the <code>javax.transaction.TransactionManager</code> to be
  63. * made available it to it (which is server-specific in standard J2EE).
  64. */
  65. NOT_SUPPORTED,
  66. /**
  67. * Execute non-transactionally, throw an exception if a transaction exists.
  68. * Analogous to EJB transaction attribute of the same name.
  69. */
  70. NEVER,
  71. /**
  72. * Execute within a nested transaction if a current transaction exists,
  73. * behave like PROPAGATION_REQUIRED else. There is no analogous feature in EJB.
  74. * <p>Note: Actual creation of a nested transaction will only work on specific
  75. * transaction managers. Out of the box, this only applies to the JDBC
  76. * DataSourceTransactionManager when working on a JDBC 3.0 driver.
  77. * Some JTA providers might support nested transactions as well
  78. */
  79. NESTED
  80. }