반응형
하이버네이트 4버전에서 5버전으로 마이그레이션을 진행하고 있는데,
테이블 생성 스크립트 코드가 변경됐다.
아래 소스코드 참조
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JpaSchemaExportTest { | |
// META-INF/persistence.xml > persistence_unit_name | |
private static final String PERSISTENCE_UNIT_NAME = "karint"; | |
@Test | |
public void createJpaSchemaExport() throws IOException { | |
Properties props = new Properties(); | |
props.put(AvailableSettings.FORMAT_SQL, "true"); | |
/*hibernate_sequence table */ | |
props.put(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, false); | |
props.put(AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "create"); | |
/* table, column ... name strategy */ | |
props.put(AvailableSettings.PHYSICAL_NAMING_STRATEGY, "com.karint.utils.SpringPhysicalNamingStrategy"); | |
props.put(AvailableSettings.HBM2DDL_DELIMITER, ";"); | |
/* export file */ | |
// props.put(AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, "create.sql"); | |
/* console */ | |
props.put(AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, new OutputStreamWriter( System.out )); | |
Persistence.generateSchema(PERSISTENCE_UNIT_NAME, props); | |
} | |
} |
위의 소스는 META-INF/persistence.xml 파일만 사용이 가능하다.
PersistenceXmlParser 파일에 98 Line에 META-INF/persistence.xml 이라고 하드코딩 되어 있다.
github : https://github.com/hulint/jpatest
반응형
'java' 카테고리의 다른 글
spring boot lazy-loading 사용시 에러 (0) | 2020.01.30 |
---|---|
springboot 핸들바 auto configuration (0) | 2019.10.08 |
openjdk 설치 (0) | 2018.12.10 |
log4j.xml 파일 위치 지정하기 (0) | 2018.04.18 |
java 인증서 추가 방법 (0) | 2018.04.13 |