@Test
void test() {
TagLevel tagLevel = new TagLevel();
tagLevelRepository.save(tagLevel);
}
---
Hibernate:
insert
into
tag_level
(created_date, modified_date, max_hashtag_count, min_hashtag_count)
values
(?, ?, ?, ?)
@Test
void test() {
TagLevel tagLevel = new TagLevel(1L);
tagLevelRepository.save(tagLevel);
}
---
Hibernate:
select
taglevel0_.tag_level_id as tag_leve1_10_0_,
taglevel0_.created_date as created_2_10_0_,
taglevel0_.modified_date as modified3_10_0_,
taglevel0_.max_hashtag_count as max_hash4_10_0_,
taglevel0_.min_hashtag_count as min_hash5_10_0_
from
tag_level taglevel0_
where
taglevel0_.tag_level_id=?
Hibernate:
insert
into
tag_level
(created_date, modified_date, max_hashtag_count, min_hashtag_count)
values
(?, ?, ?, ?)
Id만 있으면 Database에 있는 Entity라고 간주한다.
update할 항목을 확인하기 위해 select를 실행하고 일치하는 값이 없어서 insert하는 것이다.
아마 이전에 1차 캐싱을 확인하겠지! - 없어서 select
전체를 다 select하기 때문에 성능 문제 가능
@PrePersist
@PostLoad
fun markNotNew() {
isNew = false
}
@Transactional
public void practice() {
TagLevel tagLevel = tagLevelRepository.save(new TagLevel(10L, 20L));
System.out.println("@@@@@@@");
}
---
Hibernate:
insert
into
tag_level
(created_date, modified_date, max_hashtag_count, min_hashtag_count)
values
(?, ?, ?, ?)
@@@@@@@
SQL 저장소에 있는 모든 SQL문을 Flush하는 것인가?라는 궁금증이 들었다. 하지만 아니다~
@Transactional
public void practice() {
TagLevel tagLevel1 = tagLevelRepository.save(new TagLevel(10L, 20L));
tagLevel1.update(20L,30L);
TagLevel tagLevel2 = tagLevelRepository.save(new TagLevel(10L, 20L));
System.out.println("@@@@@@@");
}
---
Hibernate:
insert
into
tag_level
(created_date, modified_date, max_hashtag_count, min_hashtag_count)
values
(?, ?, ?, ?)
Hibernate:
insert
into
tag_level
(created_date, modified_date, max_hashtag_count, min_hashtag_count)
values
(?, ?, ?, ?)
@@@@@@@
Hibernate:
update
tag_level
set
created_date=?,
modified_date=?,
max_hashtag_count=?,
min_hashtag_count=?
where
tag_level_id=?
@Transactional
public void practice() {
TagLevel save = tagLevelRepository.save(new TagLevel(10L, 20L));
save.update(10L,20L);
}
---
Hibernate:
insert
into
tag_level
(created_date, modified_date, max_hashtag_count, min_hashtag_count)
values
(?, ?, ?, ?)