2012-05-03 2 views
2

현재 hibernate3-maven-plugin과 함께 최대 절전 모드 3.6.9를 사용 중이다. 나는 목표 hbm2ddl을 사용하여 SQL 스키마 파일을 생성한다.hibernate 4.1.2 빌드시 스키마 파일 생성

플러그인은 Hibernate 4.1.2를 지원하지 않습니다. 스키마 파일은 어떻게 생성합니까?

답변

2

hibernate3-maven-pluginSchemaExport을 호출하여 스키마 파일을 생성합니다. 수동으로 직접 호출하지 않는 이유는 무엇입니까?

예 :

Configuration config = new Configuration(); 

Properties properties = new Properties(); 

properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"); 
properties.put("hibernate.connection.url", "jdbc:postgresql://localhost:5432/Test"); 
properties.put("hibernate.connection.username", "username"); 
properties.put("hibernate.connection.password", "password"); 
properties.put("hibernate.connection.driver_class", "org.postgresql.Driver"); 
properties.put("hibernate.show_sql", "true"); 
config.setProperties(properties); 

config.addAnnotatedClass(MyMappedPojo1.class); 
config.addAnnotatedClass(MyMappedPojo2.class); 
.................. 

SchemaExport schemaExport = new SchemaExport(config); 

/**Just dump the schema SQLs to the console , but not execute them ***/ 
schemaExport.create(true, false);