Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Spring custom meta-annotation with redeclared attributes from meta-annotations
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})
@Transactional(transactionManager = "transactionManagerCustom")
public @interface TransactionalCustom {
@AliasFor(annotation = Transactional.class, attribute = "readOnly")
boolean readOnly() default false;

This comment has been minimized.

Copy link
Owner Author

@ghusta ghusta commented Oct 24, 2018

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment