0

I have a sample java project, in prototype phase, and I need to create DDL from JPA annotated class. Need to use hibernate,Mysql. My project is not a Maven project due to some company reasons. But I have Maven installed on system. So I created a pom.xml as per many solutions provided here and put that in my project folder. I tried to run mvn hibernate3:hbm2ddl but I'm getting following error.

INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
INFO] ------------------------------------------------------------------------
INFO] Total time: 2.059 s
INFO] Finished at: 2015-10-06T16:15:45-04:00
INFO] Final Memory: 5M/15M
INFO] ------------------------------------------------------------------------
ERROR] No plugin found for prefix 'hibernate3' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users
qxk0996.MUC\.m2\repository), central (https://repo.maven.apache.org/maven2)]

my pom looks like following

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.abcd</groupId>
    <artifactId>ft</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>ft Jersey Webapp</name>
    <build>
        <finalName>ft</finalName>
        <plugins>
            <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>ft-jpa</persistenceunit>
                        <outputfilename>schema.ddl</outputfilename>
                        <drop>false</drop>
                        <create>true</create>
                        <export>false</export>
                        <format>true</format>
                    </componentProperties>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>3.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.12</version>
        </dependency>
    </dependencies>
</project>

I've persistence.xml in webcontent/META-INF folder which looks as below.

 <persistence>
        <persistence-unit name="ft-jpa">
            <description>Ft Persistence Unit</description>
                <properties>
                <property name="javax.persistence.jdbc.url" value="-----" />
        <property name="javax.persistence.jdbc.user" value="-----" />
        <property name="javax.persistence.jdbc.password" value="-----" />
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            </properties>
        </persistence-unit>
    </persistence>

1 Answers1

1

I believe you could just add javax.persistence.schema-generation.scripts.action property to persistence.xml file. Possible values are "none", "create", "drop-and-create" and "drop".