$CLASSPATH/META-INF/persistence.xml
파일이 존재한다고 가정한다.No appropriate connection provider encountered
에러가 발생하는 것은 Persistence Unit 속성에 hibernate.hbm2ddl.auto
이 지정돼 있기 때문이다. 이를 뺄 것.import java.util.HashMap; import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.tool.hbm2ddl.SchemaExport; public class JPASchemaExport { public static void main(String[] args) { String persistenceUnitName = args[0]; String outputFile = args[1]; Ejb3Configuration cfg = new Ejb3Configuration(); HashMap<String, String> props = new HashMap<String, String>(); Ejb3Configuration configured = cfg.configure(persistenceUnitName, props); SchemaExport se = new SchemaExport(configured.getHibernateConfiguration()); se.setOutputFile(outputFile); se.setFormat(true|false); se.setDelimiter(";"); se.create(true, false); } }
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl failed: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy
<plugin> <!-- run "mvn hibernate3:hbm2ddl" to generate a schema --> <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <version>2.2</version> <configuration> <components> <component> <name>hbm2ddl</name> <implementation>jpaconfiguration</implementation> </component> </components> <componentProperties> <persistenceunit>[[PERSISTENCE_UNIT_NAME]]</persistenceunit> <outputfilename>schema.ddl</outputfilename> <drop>true</drop> <create>true</create> <export>false</export> <format>true</format> </componentProperties> </configuration> <dependencies> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.9.1</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.6.0.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>3.6.0.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.1.0.Final</version> </dependency> </dependencies> </plugin>
mvn hibernate3:hbm2ddl
명령을 실행하면된다.<implementation>jpaconfiguration</implementation>
이 부분의 값을 annotationconfiguration
으로 변경하면 JPA가 아닌 Hibernate Annotation API로 간주하게 바뀐다.<export>false</export>
의 값이 true이면 Database에 대고 DDL 명령을 실행하려들게 되므로 주의!