No, this will not work if you need additional attributes that should be set in your user annotation as follows:
@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Transactional(value = "Custom", readOnly = true, propagation = Propagation.REQUIRED) public @interface CustomTransactional { }
The solution (bad one :-)) may be to define a few annotations with the basic set of cases that you see for your scenario:
@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Transactional(value = "Custom", readOnly = true, propagation = Propagation.REQUIRED) public @interface CustomTransactionalWithRequired { } @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Transactional(value = "Custom", readOnly = true, propagation = Propagation.SUPPORTED) public @interface CustomTransactionalWithSupported { }
source share