본문 바로가기

전체 글136

[Thymeleaf] 문자열 null, empty 동시 체크 /* * Check whether a String is empty (or null). Performs a trim() operation before check */ ${#strings.isEmpty(name)} ref : https://stackoverflow.com/questions/51301074/how-to-check-null-and-empty-condition-using-thymeleaf-in-one-single-operation 2023. 9. 13.
[JPA] 같은 트랜잭션 안에서 삭제 후 저장하기 @Transactional public void test() { thisRepository.delete(entityA); thisRepository.flush(); thisRepository.save(entityB); } delete전에 save를 먼저 시도해서 제대로 저장되지 않는다. flush를 통해 변경사항을 먼저 저장하고, save 메서드를 호출한다. ref : https://stackoverflow.com/questions/27718343/spring-jparepository-delete-with-subsequent-save-in-the-same-transaction 2023. 9. 12.
[PostgreSQL] serial vs identity create table t1 (id serial primary key); create table t2 (id integer primary key generated always as identity); 결론부터 이야기하면 identity 구문을 사용하는것이 좋다. identity 구문은 실수로 값을 덮어쓰는것을 방지해주기때문이다. serial은 postgres에서 이전부터 사용되었던 방식이지만, SQL 표준을 따라가기위해 identity가 나왔다고 설명되어 있다. ref : https://stackoverflow.com/questions/55300370/postgresql-serial-vs-identity 2023. 9. 11.
[Spring] SQL 로그 보기 spring: jpa: properties: hibernate: show_sql: true format_sql: true logging: level: org: hibernate: type: trace ref : https://stackoverflow.com/questions/30118683/how-to-log-sql-statements-in-spring-boot 2023. 9. 9.