-
Notifications
You must be signed in to change notification settings - Fork 0
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
step 34 로빈 #19
base: robinjoon
Are you sure you want to change the base?
step 34 로빈 #19
Conversation
트랜잭션 적용하면서 해당 로직의 필요성이 없어졌다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로빈, 안녕하세요~ 망쵸입니다!
코드 잘 봤어요. JDBC, DB와 관련된 코드가 인상적이었어요 💯
덕분에 제가 학습하지 못한 부분을 학습할 수 있었어요.
레벨1 정말 고생 많았고, 레벨2도 열심히 해보아요 ✊✊
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class PiecesOnChessBoardDAOForMysql implements PiecesOnChessBoardDAO { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
특정 DB에 매우 종속적인 네이밍이네요! 구현체니까 괜찮은 것 같아요. 다만, 다소 길다는 느낌은 있네요!
private record DBConnectionParameters(String url, String userName, String password) { | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
내부 클래스를 이렇게 잘 사용할 수 있네요! 사소하지만 대단하다고 느껴지네요 👍
startTransaction(connection); | ||
if (isSaveDataExist()) { | ||
List<Piece> pieces = piecesOnChessBoardDAO.selectAll(connection); | ||
Team currentTeam = turnDAO.select(connection).get(); | ||
commitTransaction(connection); | ||
return new ChessGame(pieces, currentTeam); | ||
} | ||
piecesOnChessBoardDAO.deleteAll(connection); | ||
turnDAO.delete(connection); | ||
commitTransaction(connection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
트랜잭션 구현 멋지네요.. 👍
startTransaction(connection); | ||
if (canNotSave(connection)) { | ||
return false; | ||
} | ||
boolean saveAllPiecesSuccess = piecesOnChessBoardDAO.saveAll(piecesOnBoard, connection); | ||
Team currentTeam = chessGame.currentTeam(); | ||
boolean saveTurnSuccess = turnDAO.save(currentTeam, connection); | ||
commitTransaction(connection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
트랜잭션을 거는 코드가 반복되는데, 개선할 방법은 없을까요? 고민해 보셨다면, 이렇게 작성한 근거가 궁금해요 💭
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
public class ChessPersistence { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
클래스명에 Persistence를 넣은 의도는 알 것 같은데, 개인적으로 의미가 명확하게 와닿지 않네요!
private static class FakeConnection implements Connection { | ||
|
||
@Override | ||
public Statement createStatement() throws SQLException { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아직 미완성인 건가요? 🤔
import org.junit.jupiter.api.Test; | ||
|
||
class TurnDAOForMysqlTest { | ||
private static final String DB_URL = "jdbc:mysql://localhost:13306/chess2?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로덕트와 다른 DB를 사용하셨네요! 이 방법을 선택한 이유가 있을까요?
원본 PR 참고해주세여
woowacourse#749