1

How to generate java classes from hibernate plugin?

I tried the online guides like these

How to configure maven hbm2hbmxml and hbm2java to run one after the other in mvn clean install

but I can not generate them.

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
sasha
  • 31
  • 4
  • It'll be good if you post more information, like your `hibernate3-maven-plugin` plugin configuration from pom.xml, `your.reveng.xml`, `your.hibernate.properties`, commands you ran and output with statcktrace if there was an exception. – ootero Mar 06 '18 at 21:41
  • I solved thanks to this post https://stackoverflow.com/questions/7498174/hbm2java-failedunable-to-load-class-declared-as-mapping-class-com-dss-domain – sasha Mar 08 '18 at 14:18

1 Answers1

0

pom.xml

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>hbm2java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <components>
                        <component>
                            <name>hbm2java</name>
                            <implementation>configuration</implementation>
                            <outputDirectory>target/generated-sources</outputDirectory>
                        </component>
                    </components>
                    <componentProperties>
                        <goal>hbm2java</goal>
                        <revengfile>/src/main/resources/model.reveng.xml</revengfile>
                        <configurationfile>/src/main/resources/hibernate.cfg.xml</configurationfile>
                        <drop>true</drop>
                        <jdk5>true</jdk5>

                    </componentProperties>
                </configuration>
            </plugin>

model.reveng.xml

<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >


<hibernate-reverse-engineering>
<schema-selection match-schema = "my_db" />
</hibernate-reverse-engineering>

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <!-- Database connection settings -->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/my_db</property>
        <property name="hibernate.connection.username">user</property>
        <property name="hibernate.connection.password">pass</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>

        </session-factory>
</hibernate-configuration>

BUILD SUCCESS but in the target folder no class.

sasha
  • 31
  • 4