2022-03-15-tIL

Today I Learned

JPA Entity Without Setters

우선 JPA가 내부적으로 처리할 때 getter나 setter를 사용하는 동작은 없다. 자바 리플렉션 등을 이용해서 직접 접근이 가능하기 때문이다. 그렇다면 getter는 어느정도 사용한다고 하더라도(리팩터링 하기전에 빠른개발을 위해), setter은 변경이 일어나는 지점에 대해 관리 포인트가 너무 많이 늘어나게 되므로 사용을 지양하는게 바람직하다.

  • https://n1tjrgns.tistory.com/255
  • https://community.oracle.com/tech/developers/discussion/1573834/jpa-and-entities-without-setter-methods
  • https://geminikim.medium.com/%EA%B0%9C%EC%9D%B8%EC%B7%A8%ED%96%A5-jpa-%EC%82%AC%EC%9A%A9%EA%B8%B0-2%ED%8E%B8-entity-with-getter-setter-and-test-a0305af69090
  • https://thorben-janssen.com/access-strategies-in-jpa-and-hibernate/
  • https://blog.naver.com/PostView.nhn?blogId=qjawnswkd&logNo=222088532641
  • https://www.xavierbouclet.com/2019/05/10/Jpa-and-private-setter-and-private-constructor.html
  • https://stackoverflow.com/questions/12369641/is-there-any-reason-to-not-generate-setters-and-getters-for-id-fields-in-jpa
  • https://velog.io/@aidenshin/%EB%82%B4%EA%B0%80-%EC%83%9D%EA%B0%81%ED%95%98%EB%8A%94-JPA-%EC%97%94%ED%8B%B0%ED%8B%B0-%EC%9E%91%EC%84%B1-%EC%9B%90%EC%B9%99
  • https://cheese10yun.github.io/spring-jpa-best-06/
  • https://stackoverflow.com/questions/2676689/does-hibernate-always-need-a-setter-when-there-is-a-getter
  • https://stackoverflow.com/questions/6033905/create-the-perfect-jpa-entity
  • https://stackoverflow.com/questions/13650905/hibernate-entity-attribute-with-getter-but-without-setter-propertynotfoundexce

아파치 StringUtils vs 스프링 StringUtils

  • https://hahaha2016.tistory.com/4
  • https://stackoverflow.com/questions/55136885/org-apache-commons-lang3-stringutils-vs-org-apache-logging-log4j-util-strings
  • http://itpsolver.com/%ED%8E%8C%EA%B8%80-%EC%8A%A4%ED%94%84%EB%A7%81%EC%9D%98-stringutils-%EB%A9%94%EC%84%9C%EB%93%9C-%EC%A0%95%EB%A6%AC/
  • https://recordsoflife.tistory.com/474
  • https://www.baeldung.com/java-commons-lang-3
  • https://stackoverflow.com/questions/7337070/apaches-stringutils-isblankstr-vs-guavas-strings-isnulloremptystr-should

StringUtils.isBlank() vs StringUtils.isEmpty()

  • https://stackoverflow.com/questions/23419087/stringutils-isblank-vs-string-isempty
  • https://commons.apache.org/proper/commons-lang/javadocs/api-3.9/org/apache/commons/lang3/ObjectUtils.html
  • https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/util/ObjectUtils.html

ObjectUtils.isEmpty()

  • https://blog.naver.com/PostView.naver?blogId=dktmrorl&logNo=222355031997&parentCategoryNo=&categoryNo=42&viewDate=&isShowPopularPosts=false&from=postView

백엔드에서 에러 처리

이전의 직장에서 B2C 서비스 앱을 개발하던 중에 throw new로 예외를 컨트롤러에서 터뜨리는 식의 구현을 한적이 있었다. 그래서 앱 전체가 실행이 안되는 문제가 발생했다. 이러한 경우에는 예외를 catch하더라도 로그만 찍고 빈 값이라도 리턴하라고 했다. 하지만 로그만 찍고 빈값을 리턴하는 것도 바람직한 방법은 아니다. 로그도 찍고 리턴을 감싸서 어떤 예외가 발생했는지 정보를 최대한 포함시키는 것이 바람직하다. 에러의 원인이 무엇인지 프론트에서도 확인할 수 있게 하는것이 후자의 방법이고, 최후의 방법으로 서버에 직접 들어가서 로그를 보는(혹은 에러 모니터링 툴을 통해) 용도가 로그이다.

  • https://velog.io/@alvin/%EB%B0%B1%EC%97%94%EB%93%9C%EC%97%90%EC%84%9C%EC%9D%98-%EC%97%90%EB%9F%AC-%EC%B2%98%EB%A6%AC%EC%97%90-%EB%8C%80%ED%95%9C-%EA%B3%A0%EC%B0%B0
  • https://evan-moon.github.io/2020/03/15/about-http-status-code/
  • https://jaimemin.tistory.com/1890
  • https://cheese10yun.github.io/spring-guide-exception/
  • https://www.popit.kr/spring-guide-%EC%97%90%EC%99%B8-%EC%B2%98%EB%A6%AC-%EC%A0%84%EB%9E%B5/

아파치와 톰캣

  • https://limmmee.tistory.com/4

MyBatis @MapppedTypes

  • https://mybatis.org/mybatis-3/ko/configuration.html