http://static.springframework.org/spring/docs/2.0.x/reference/transaction.html#transaction-declarative

위 사이트의 9.5.6. Using @Transactional 부분.

첫째, @Transactional은 인터페이스(및 메소드), 구현클래스(및 public 메소드)에 붙일 수 있다.
특히나 public 메소드에만 적용되는 점은 아래와 같이 설명하고 있다.
Method visibility and @Transactional

When using proxies, the @Transactional annotation should only be applied to methods with public visibility. If you do annotate protected, private or package-visible methods with the @Transactional annotation, no error will be raised, but the annotated method will not exhibit the configured transactional settings. Consider the use of AspectJ (see below) if you need to annotate non-public methods.

둘째, self-invocation 상황(내부 호출)에서는 적용되지 않는다. 즉 외부의 클래스에서 그 메소드를
호출해야 트랜잭션이 걸린다.

Note: Since this mechanism is based on proxies, only 'external' method calls coming in through the proxy will be intercepted. This means that 'self-invocation', i.e. a method within the target object calling some other method of the target object, won't lead to an actual transaction at runtime even if the invoked method is marked with @Transactional!

며칠 동안 두가지 상황을 모두 겪으면서 삽집한 생각을 하면... 으 ...... 바보같다.. ㅠ.ㅠ

궁금점 : @Transactional을 Class 선언부에 안붙이고 메소드에만 붙이면 어떻게 되는거지?
여기저기 찾아보면 당최 메소드에만 붙어있는 예제가 없다.


Posted by 에코지오
,
본격적으로 TDD를 수행하기 위해 노력하고 있는 요즘,
mock 객체의 필요성을 느끼고 있다.

jmock, easymock 둘 중 어떤 것을 데리고 놀까 고민하다가 초보학습자에게 좋은
easymock으로 결론짓고 자료를 검색하니,

역시나 기선님 자료가 위에 랭크되어 나온다... (기선님 쵝오 ^^b)

http://whiteship.tistory.com/search/easymock

2008/03/02 EasyMock - Using Stub Behavior for Methods
2008/03/02 EasyMock - Flexible Expectations with Argument Matchers
2008/03/02 EasyMock - Strict Mocks, Switching Order Checking On and Off
2008/03/01 EasyMock - Relaxing Call Counts
2008/03/01 EasyMock - Changing Behavior for the Same Method Call
2008/03/01 EasyMock - Creating Return Values or Exceptions
2008/03/01 EasyMock - Working with Exceptions
2008/03/01 EasyMock - Specifying Return Values
2008/03/01 EasyMock - Expecting an Explicit Number of Calls (2)
2008/02/06 EasyMock으로 클래스의 Mock 객체 만들기
2007/08/22 인터페이스를 사용할 때와 안 할 때의 테스팅 차이
2007/06/22 Spring MVC 리팩토링 4
2007/06/21 AbstractModelAndViewTests 사용하여 Controller 테스트하기
2007/06/19 Testing Controller
2007/06/19 EasyMock을 사용한 Service 계층 테스트2
2007/06/18 EasyMock을 사용한 Service 계층 테스트1
2007/04/09 Testing (2)
2007/04/08 이번 주 할 일
2006/12/30 주소록 개발 카탈로그 (4)
2006/12/17 중간점검
2006/12/11 페이징 기능 구현하기(TDD, Easymock, iBATIS, MySQL) (2)
2006/12/06 Easymock 연습하기 3탄
2006/12/05 Easymock 연습하기 2탄
2006/12/05 Easymock 연습하기
2006/12/05 단위 테스트 모르겠슴 ㅠ.ㅠ
2006/10/08 Layers of Abstractions

이제 남은 일은 공부하고 직접 돌려보는 것뿐.
Posted by 에코지오
,
하이버네이트는 항상 느끼는 거지만 코딩할 때마다 헷갈리는 부분이 많다.

늦은로딩, 페칭, 세션, 캐쉬, 객체연관, 객체상태, DB와 동기화 시점 등등.

어떡하지...? 뭘 어떡하나. 부지런히 자료찾아보고 테스트하고 메모해나가는 수밖에....

이미 그런 분들이 꽤 계시다...  특히 기선님하이버네이트3 책 요약 시리즈

나처럼 우매한 대중에게는 너무 고마운 자료다.

일단 기초적인거 하나 붙잡고 읽어보자.
 
하이버네이트 API: 저장하고 읽어들이기

session.load() 메소드 사용팁을 잘 정리해주셨다.

DB에 있는 객체 하나를 꺼내서 다른 객체에 세팅해줘야 하는 경우. Comment.setForAuction(item). 이 경우 굳이 item은 load()로 가져와도 된다. 굳이 DB에서 전부 가져올 필요가 없다. Comment를 저장할 때, item의 id를 외례키로 저장하게 되는데, load()로 가져온 Proxy가 딱 그 id만 가지고 있기 때문이다

session.delete() 호출후 식별자를 제거하기 위한 팁도 있다.

Transient 상태가 될 때, 식별자도 제거하려면 hibernate.use_identifier_rollback 이 설정을 해줘야돼.

다른 글도 읽어보자. 다 피가 되고 살이 된다.
 

Posted by 에코지오
,