1

I have a custom strategy but I can't figure out how to get this plugin to use it.

My relevent pom section is:

<build>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.1.RELEASE</version>
        </plugin>

        <plugin>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-tools-maven-plugin</artifactId>
            <version>5.4.1.Final</version>
            <executions>
                <execution>
                    <id>Display Help</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>help</goal>
                    </goals>
                </execution>
                <execution>
                    <id>Entity generation</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>hbm2java</goal>
                    </goals>
                    <configuration>
                        <templatePath>src/main/resources/templates/</templatePath>
                        <!-- Defaults: -->
                        <outputDirectory>generated-sources/</outputDirectory>
                        <ejb3>false</ejb3>
                        <jdk5>false</jdk5>
                    </configuration>
                </execution>
                <execution>
                    <id>Schema generation</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>hbm2ddl</goal>
                    </goals>
                    <configuration>
                        <!--Possible targetType: SCRIPT (default), STDOUT, DATABASE -->
                        <targetTypes>
                            <param>SCRIPT</param>
                            <param>STDOUT</param>
                            <param>DATABASE</param>
                        </targetTypes>
                        <!-- Defaults: -->
                        <outputDirectory>generated-resources/</outputDirectory>
                        <!--Possible schemaExportAction: CREATE (default), DROP, BOTH -->
                        <schemaExportAction>CREATE</schemaExportAction>
                        <outputFileName>schema.ddl</outputFileName>
                        <delimiter>;</delimiter>
                        <haltOnError>true</haltOnError>
                        <format>true</format>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <revengFile>src/main/hibernate/hibernate.reveng.xml</revengFile>
                <!-- Defaults: -->
                <packageName></packageName>
                <configFile>src/main/hibernate/hibernate.cfg.xml</configFile>
                <detectManyToMany>true</detectManyToMany>
                <detectOneToOne>true</detectOneToOne>
                <detectOptimisticLock>true</detectOptimisticLock>
                <createCollectionForForeignKey>true</createCollectionForForeignKey>
                <createManyToOneForForeignKey>true</createManyToOneForForeignKey>
            </configuration>
            <dependencies>
                <!-- databases -->
                <dependency>
                    <!-- DB Driver of your choice -->
                    <groupId>com.oracle</groupId>
                    <artifactId>oracle-jdbc8</artifactId>
                    <version>18</version>
                </dependency>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>42.2.1</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>

    <pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                    <version>5.4.1.Final</version>
            </plugin>
            <!--  
            <plugin>
                <groupId>org.springframework.boot</groupId>
            </plugin>
            -->
        </plugins>
    </pluginManagement>

</build>

And my hibernate.reveng.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.org/dtd/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>

    <type-mapping>
        <sql-type jdbc-type="DATE" hibernate-type="java.time.LocalDate"/>
        <sql-type jdbc-type="TIMESTAMP" hibernate-type="java.time.LocalDateTime"/>
    </type-mapping>

</hibernate-reverse-engineering>

Additionally, although in the config I have specified to use "src/main/hibernate/hibernate.cfg.xml" it is reading "hibernate.properties"

I guess the example I got https://github.com/stadler/hibernate-tools-maven-plugin has the wrong configuration property name.

So:

1) The initial question

2) How do I configure this to use the specified configuration file?

3) Where is there a list of all the configuration problems and finally despite having

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                    <version>5.4.1.Final</version>
            </plugin>
        </plugins>
    </pluginManagement>

I am getting "plugin execution not covered by lifecycle" in eclipse

So apparently I did not correctly follow this StackOverflow answer How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds

user939857
  • 377
  • 5
  • 19

1 Answers1

1

The documentation says add a revengStrategy configuration to the plugin with the full name of the class that extends DefaultReverseEngineeringStrategy. However when you try this, it throws class not instanced error. I have raised an issue with hibernate tools.

However, I have seen solutions where this is working if you have multi module project. The custom class should be part of a different module and that module should be added as a plugin dependency.

If I hear back from hibernate tools, you can find it here later https://jonamlabs.com/how-to-use-hibernate-tools-maven-plugin-to-generate-jpa-entities-from-an-existing-database/

Manoj Reddy
  • 134
  • 8
  • any news from that? same issue not understanding where to specify the class extending DelegatingReverseEngineeringStrategy – Pipo Sep 05 '22 at 19:59