-
Notifications
You must be signed in to change notification settings - Fork 3
로버트는 얼마나 좋았을까 풀 코스 회의 (2023‐08‐15)
Jiwon Choi edited this page Aug 29, 2023
·
1 revision
main ← dev
: 일반 Merge
dev ← xxx
: squash Merge
dev
가 Merge 되면 dev to feat
로 머지해야한다.
member 가 auth , member 정보가 많아지면
Member_Info 로 테이블 분리
http://localhost:8080/h2-console 접속
application-local (임시) 아직반영안되어 올립니다
spring:
jpa:
hibernate:
ddl-auto: validate
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
format_sql: true
sql:
init:
schema-locations: classpath:schema.sql
mode: always
datasource:
url: jdbc:h2:mem:testdb;MODE=MySQL
driver-class-name: org.h2.Driver
username: sa
password:
h2:
console:
enabled: true
http://localhost:8080/h2-console
h2 console 보기
public class DatabaseCleaner implements InitializingBean {
@PersistenceContext
private EntityManager entityManager;
private List<String> tableNames;
@Override
public void afterPropertiesSet() {
tableNames = entityManager.getMetamodel().getEntities().stream()
.filter(entityType -> entityType.getJavaType().getAnnotation(Entity.class) != null)
.map(entityType -> CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entityType.getName()))
.collect(Collectors.toList());
}
@Transactional
public void tableClear() {
entityManager.flush();
entityManager.clear();
entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY FALSE").executeUpdate();
for (String tableName : tableNames) {
entityManager.createNativeQuery("TRUNCATE TABLE " + tableName).executeUpdate();
}
entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY TRUE").executeUpdate();
}
}
중요하다고 생각하는 부분을 제일 위로 두고 순차적으로 덜 중요한 어노테이션을 달자!
entity
table
No
All
req
get