program tip

hbm2ddl을 끄는 방법?

radiobox 2020. 12. 29. 06:55
반응형

hbm2ddl을 끄는 방법?


hbm2ddl을 끄는 방법에 대한 참조를 찾을 수 없습니다.


생략하면 hibernate.hbm2ddl.auto기본적으로 Hibernate가 아무것도하지 않습니다. 참조 문서에서 :

1.1.4. Hibernate 구성

hbm2ddl.auto옵션은 데이터베이스 스키마를 데이터베이스로 직접 자동 생성합니다. 구성 옵션을 제거하여 끄 거나 SchemaExport Ant 태스크를 사용하여 파일로 경로 재 지정할 수도 있습니다 .

(문서화되지 않음)으로 설정 hbm2ddl.auto하면 none다음과 같은 경고가 생성 될 수 있습니다.org.hibernate.cfg.SettingsFactory - Unrecognized value for "hibernate.hbm2ddl.auto": none


다음 방법으로 끌 수 있습니다.

hibernate.hbm2ddl.auto=none

문서화되지 않았지만 값을 매길 수 없습니다!


이것을 명확히하기 위해서는 소스를 조사해야합니다 org.hibernate.cfg.SettingsFactory(사용 된 버전에 따라 다른 것을 볼 수 있습니다) :

String autoSchemaExport = properties.getProperty( AvailableSettings.HBM2DDL_AUTO );
if ( "validate".equals(autoSchemaExport) ) {
    settings.setAutoValidateSchema( true );
}
else if ( "update".equals(autoSchemaExport) ) {
    settings.setAutoUpdateSchema( true );
}
else if ( "create".equals(autoSchemaExport) ) {
    settings.setAutoCreateSchema( true );
}
else if ( "create-drop".equals( autoSchemaExport ) ) {
    settings.setAutoCreateSchema( true );
    settings.setAutoDropSchema( true );
}
else if ( !StringHelper.isEmpty( autoSchemaExport ) ) {
    LOG.warn( "Unrecognized value for \"hibernate.hbm2ddl.auto\": " + autoSchemaExport );
}

에서 org.hibernate.cfg.Settings수업이 변수는 다음과 같이 초기화된다 :

private boolean autoCreateSchema;
private boolean autoDropSchema;
private boolean autoUpdateSchema;
private boolean autoValidateSchema;

따라서 기본값은 false입니다.

hibernate.hbm2ddl.auto설정을 생략하면 HBM2DDL_AUTO제안 된대로 기능이 꺼지지 hibernate.hbm2ddl.auto = none만 후자의 경우 로그에 경고가 표시됩니다.


hibernate.properties에서

hibernate.hbm2ddl.auto=validate

물론 구성 할 위치는 최대 절전 모드를 구성하는 방법에 따라 다릅니다. 프로그래밍 방식으로 구성되어있는 경우 속성을 설정하십시오. hibernate.cfg.xml에서 가져온 경우 :

<property name="hibernate.hbm2ddl.auto">validate</property>

지원되지 않는 값을 입력하면 지원되는 값을 알려줍니다. o.h.b.i.SessionFactoryBuilderImpl : Unrecognized hbm2ddl_auto value : bla. Supported values include 'create', 'create-drop', 'update', 'none' and 'validate'. Ignoring

그리고이 값 none은 기본값이며 공식적으로 지원되고 문서화됩니다 : https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#configurations-hbmddl


이 속성은 필수가 아닙니다. hibernate.hbm2ddl.autoxml 파일에서 항목을 완전히 삭제 하십시오.

참조 URL : https://stackoverflow.com/questions/3179765/how-to-turn-off-hbm2ddl

반응형