Hibernate Reverse Engineering

I have an existing PostgreSQL DB. I need to generate the Java classes. The IDE and tools I’m using are chosen by employer. Basically, I’m trying to set up a Maven Build that will connect to the Postgres DB and then generate the Java code for me (with all of the appropriate annotations so that they can be compiled and then imported into Drools. I just can’t find any documentation what will explain how this would be done. I have spent hours at it and there are always missing classes or configuration with undecipherable messages (i.e. a missing class with no clue on how to resolve it).

One example of one of the issues I’m having right now is that it says the driver for the DB is missing yet it is in the hibernate.properties file and the hibernate.cfg.xml file.

Where is a document (not a video since those are too hard to reference). That explains how to do this with a Maven Build job?

Thanks,
Tom

If you don’t want to use Eclipse JBoss Tools which provides you a great UI to setup initial configuration, you can take a look at this StackOverflow post that provides a simple example: java - How to configure maven hbm2hbmxml and hbm2java to run one after the other in mvn clean install - Stack Overflow

Hi,
That was nice, it was a working example (almost, but after some tweaking, I got it to work). However; it would be really nice if you could point me to the documentation. For example:
Default batch fetch size: 1
[INFO] Generate SQL with comments: disabled
[INFO] Order SQL updates by primary key: disabled
[INFO] Order SQL inserts for batching: disabled
[INFO] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[INFO] Using ASTQueryTranslatorFactory
[INFO] Query language substitutions: {}
[INFO] JPA-QL strict compliance: disabled
[INFO] Second-level cache: enabled
[INFO] Query cache: disabled
[INFO] Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
[INFO] Optimize cache for minimal puts: disabled
[INFO] Structured second-level cache entries: disabled
[INFO] Echoing all SQL to stdout
[INFO] Statistics: disabled
[INFO] Deleted entity synthetic identifier rollback: disabled
[INFO] Default entity-mode: pojo

All these “option values” are listed, but I don’t know where to find the definition of them so that I know whether or not they should be adjusted.

One other question, is this the latest version?

Thanks,
Tom

I’m sorry, forget about the stackoverflow post. I just saw that it uses an outdated plugin.

Here is the actual officially supported plugin: hibernate-tools/maven at master · hibernate/hibernate-tools · GitHub

Hi @beikov How to do this for latest hibernate 6 as there is no plugin for latest 6 series as there is no plugin for hibernate 6 and Hibernate JBoss tools is having some problems with Jakarta persistence.

I have explained this in detail here [Unable to generate POJO entities with annotations using hibernate tools 6.2 Series - Hibernate Tools - Hibernate] (Unable to generate POJO entities with annotations using hibernate tools 6.2 Series)

Can you help me?