javahibernate-5.xhibernate3

Where is the "Reverse Engineering" feature in Hibernate5?


I'm upgrading an old project from hibernate3 to hibernate5. The project has a dependency on hbm2java (the so-called reverse engineering tool). In the old project this was executed with mvn hibernate3:hbm2java.

Unfortunately, hbm2java is nowhere to be found in Hibernate5 - not in the code, not in the documentation.

What is the Hibernate5 equivalent of the old hbm2java? Or in case it's no longer supported, what's the closest alternative? I'm willing to get out of Hibernate entirely, if that's what it takes to get out of Hibernate 3.


Solution

  • Suggestion#1:

    You can use maven ant runner. It may help.

    mvn antrun:run@hbm2java
    

    If you have modified templates (see the documentation) then, in pom.xml, modify the hibernate tool tag to look like:

    <hibernatetool templatepath="src/the/path/to/the/directory/containing/pojo/directory">
    

    The above path must point to the parent of the directory named pojo, containing your templates.

    Also, if you have a custom reverse engineering strategy class the, in pom.xml add this attribute to jdbcconfiguration tag.

    reversestrategy="fully.qualified.name.CustomDelegatingReverseEngineeringStrategy"
    

    Resource Link: Hibernate tools reverse engineering using Maven

    I haven't checked it but you can try with this procedure using Hibernate 5.X version.


    Suggestion#2:

    This issue seems critical in Hibernate 5.x version. All recommendation is to use 4.3 version for reverse engineering instead of 5.x

    Resource Link: https://stackoverflow.com/a/37577315

    Step by step tutorial to use 4.3 instead of 5.1 with pictorial view is given here: http://o7planning.org/en/10125/using-hibernate-tools-generate-entity-classes-from-tables

    Some issues are given below:

    1. Database case-sensitive issue
    2. type mapping
    3. table filtering
    4. no <schema-selection> tag is specified

    This issues is required to resolve by hand (it's just basic XML) or you can use the Hibernate plugins, which provides a specialized editor. http://www.hibernate.org/30.html

    For reverse engineering rule, you can go through this tutorial: Chapter 6. Controlling reverse engineering