Freemarker templates to generate Field-based JPA annotations for POJO

Hi all,

After a long time, I’m dealing again with freemarker templates to customize POJO/DAO generation via hibernate-tools on Eclipse (from the latest Red Hat Developer Studio).

The goal is to generate java code compliant with Panache and JPA:
What I get from standard pojo generation:

...
@Entity
@Table(name = "dom_continent", schema = "core")
public class DomContinent implements java.io.Serializable {

    private String code;
    private String name;
    private Set<DomCountry> domCountries = new HashSet<DomCountry>(0);

    public DomContinent() {
    }

    public DomContinent(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public DomContinent(String code, String name,
            Set<DomCountry> domCountries) {
        this.code = code;
        this.name = name;
        this.domCountries = domCountries;
    }

    @Id

    @Column(name = "code", unique = true, nullable = false, length = 2)
    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Column(name = "name", nullable = false, length = 12)
    public String getName() {
        return this.name;
    }
...

what I want to produce using the custom templates:

@Entity
@Table(name = "dom_continent", schema = "core")
public class DomContinent extends PanacheEntityBase {

    @Id
    @Column(name = "code", unique = true, nullable = false, length = 2)
    public String code;

    @Column(name = "name", nullable = false, length = 12)
    public String name;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "domContinent")
    public Set<DomCountry> domCountries = new HashSet<DomCountry>(0);

}

As usual, I’ve set up the database connection in eclipse and set up the hibernate configuration to rely on that.
Due to some issues with the latest version of Hibernate orm, I’ve set the Hibernate version in the configuration to 5.2.

I have successfully created a reverse engineering config to filter tables using the UI as well.

Digging into the internet I found this post on stackoverflow recommending the implementation of an additional template to generate annotations based on field info, rather than property information.

Unfortunately, that solution is not generating the expected outcome and fails to generate annotations for table relationships.

Could you please provide guidance or a link to a packaged solution to solve my problem?

Thanks a lot in advance and kind regards,

Andrea