-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[7주차](이세원, 김동하, 박준영) #8
Labels
Comments
📚6.7 ~ 6.9장 정리트랜잭션 애노테이션
@transactional
@Transactional(readOnly=true) @Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Transactional {
@AliasFor("transactionManager")
String value() default "";
@AliasFor("value")
String transactionManager() default "";
String[] label() default {};
Propagation propagation() default Propagation.REQUIRED;
Isolation isolation() default Isolation.DEFAULT;
int timeout() default TransactionDefinition.TIMEOUT_DEFAULT;
String timeoutString() default "";
boolean readOnly() default false;
Class<? extends Throwable>[] rollbackFor() default {};
String[] rollbackForClassName() default {};
Class<? extends Throwable>[] noRollbackFor() default {};
String[] noRollbackForClassName() default {};
} 트랜잭션 속성을 이용하는 포인트컷
대체 정책
[1]
public interface Service {
[2]
void method1();
[3]
void method2();
}
[4]
public class Servicelmpl implements Service {
[5]
public void method1() (
[6]
public void method2() {
}
트랜잭션 애노테이션 적용
@Transactional
public interface UserService {
void upgradeLevels();
void add(User user);
@Transactional(readOnly = true) // default : false
User get(String id);
@Transactional(readOnly = true)
List<User> getAll();
void deleteAll();
void update(User user);
} 장점
단점과 주의사항
@transactional 테스트테스트를 위한 트랜잭션 애노테이션@transactional
@Rollback
public class UserServiceTest {
...
@Test
@Transactional
@Rollback(false)
public void transactionSync() {
...
}
} @TransactionConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/applicationContext.xml")
@Transactional
@TransactionConfiguration(defaultRollback = false) //롤백되지 않음
public class UserServiceTest {
@Test
@Rollback //롤백됨
public void add(){}
} @NotTransactional과 Propagation.NEVER
@Transactional(propagation = Propagation.NEVER) 정리
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: