@Test
public void findTransactionList_all_test() throws Exception {
// given
Long accountId = 1L;
// when
List<Transaction> transactionListPS = transactionRepository.findTransactionList(accountId, "ALL", 0);
transactionListPS.forEach((transaction) -> {
System.out.println("테스트 : " + transaction.getId());
System.out.println("테스트 : " + transaction.getAmount());
System.out.println("테스트 : " + transaction.getSender());
System.out.println("테스트 : " + transaction.getReceiver());
System.out.println("테스트 : " + transaction.getWithdrawAccountBalance());
System.out.println("테스트 : " + transaction.getDepositAccountBalance());
System.out.println("테스트 : ===============================");
});
// then
}
update가 날라가는 이유는 더티채킹이 되지 않아서 우리가 따로 save한 것 때문에
select
transactio0_.id as id1_1_0_,
account1_.id as id1_0_1_,
account2_.id as id1_0_2_,
transactio0_.amount as amount2_1_0_,
transactio0_.create_at as create_a3_1_0_,
transactio0_.deposit_account_id as deposit11_1_0_,
transactio0_.deposit_account_balance as deposit_4_1_0_,
transactio0_.gubun as gubun5_1_0_,
transactio0_.receiver as receiver6_1_0_,
transactio0_.sender as sender7_1_0_,
transactio0_.tel as tel8_1_0_,
transactio0_.update_at as update_a9_1_0_,
transactio0_.withdraw_account_id as withdra12_1_0_,
transactio0_.withdraw_account_balance as withdra10_1_0_,
account1_.balance as balance2_0_1_,
account1_.create_at as create_a3_0_1_,
account1_.number as number4_0_1_,
account1_.password as password5_0_1_,
account1_.update_at as update_a6_0_1_,
account1_.user_id as user_id7_0_1_,
account2_.balance as balance2_0_2_,
account2_.create_at as create_a3_0_2_,
account2_.number as number4_0_2_,
account2_.password as password5_0_2_,
account2_.update_at as update_a6_0_2_,
account2_.user_id as user_id7_0_2_
from
transaction_tb transactio0_
left outer join
account_tb account1_
on transactio0_.withdraw_account_id=account1_.id
left outer join
account_tb account2_
on transactio0_.deposit_account_id=account2_.id
where
transactio0_.withdraw_account_id=?
or transactio0_.deposit_account_id=? limit ?
한방쿼리 left outer join을 사용했기 때문에, 동적쿼리 사용된 것
다음과 같이 주석 처리 후 실행
이걸로 알 수 있는 것 : Repository는 더티채킹 O, Controller는 더티채킹 X, 따라서 일단 다음과 같이 코드를 작성하면 2개의 경우 모두 가능