Created
October 24, 2018 07:05
-
-
Save ghusta/75e20ca2613e5d85965fa9d3801cce2b to your computer and use it in GitHub Desktop.
Spring custom meta-annotation with redeclared attributes from meta-annotations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.core.annotation.AliasFor; | |
import org.springframework.transaction.annotation.Transactional; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
/** | |
* Meta-annotation Spring. | |
* | |
* @see Transactional | |
*/ | |
@Target({ElementType.METHOD, ElementType.TYPE}) | |
@Retention(RetentionPolicy.RUNTIME) | |
@Transactional(transactionManager = "transactionManagerCustom") | |
public @interface TransactionalCustom { | |
@AliasFor(annotation = Transactional.class, attribute = "readOnly") | |
boolean readOnly() default false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@TransactionalCustom
is a meta-annotation for@Transactional
.The
readOnly
attribute from@Transactional
is redeclared to allow its use directly from@TransactionalCustom
.See documentation : Spring Meta-annotations