Annotation Type Transactional


  • @Target({METHOD,TYPE})
    @Retention(RUNTIME)
    @Inherited
    public @interface Transactional
    Any method or class marked with this annotation will be considered for transactionality. Consult the documentation on https://github.com/google/guice/wiki/GuicePersist for detailed semantics. Marking a method @Transactional will start a new transaction before the method executes and commit it after the method returns.

    If the method throws an exception, the transaction will be rolled back unless you have specifically requested not to in the ignore() clause.

    Similarly, the set of exceptions that will trigger a rollback can be defined in the rollbackOn() clause. By default, only unchecked exceptions trigger a rollback.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      Class<? extends Exception>[] ignore
      A list of exceptions to not rollback on.
      Class<? extends Exception>[] rollbackOn
      A list of exceptions to rollback on, if thrown by the transactional method.
    • Element Detail

      • rollbackOn

        Class<? extends Exception>[] rollbackOn
        A list of exceptions to rollback on, if thrown by the transactional method. These exceptions are propagated correctly after a rollback.
        Default:
        {java.lang.RuntimeException.class}
      • ignore

        Class<? extends Exception>[] ignore
        A list of exceptions to not rollback on. A caveat to the rollbackOn clause. The disjunction of rollbackOn and ignore represents the list of exceptions that will trigger a rollback. The complement of rollbackOn and the universal set plus any exceptions in the ignore set represents the list of exceptions that will trigger a commit. Note that ignore exceptions take precedence over rollbackOn, but with subtype granularity.
        Default:
        {}