0

I use the Hibernate Reverse Engineering through JBoss Tools > Hibernate Tools to generate Model Classes.

There, when I add the Hibernate Configuration and Run it / Rebuild It, it list all the DBs although I mention only one DB in the hibernate.cfg.xml's hibernate.connection.url. eg : jdbc:mysql://localhost:3306/booksdb.

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/booksdb</property>
        <property name="hibernate.connection.username">xxxx</property>
        <property name="hibernate.connection.password">xxxx</property>
    </session-factory>
</hibernate-configuration>

enter image description here

Then when I generate the entities code it scans all other Database tables also to generate the entity codes for all. Sometimes it impact by some duplicated tables in different DBs.

Question : How to do this for single database mentioned in the hibernate.connection.url?

Hibernate Code Generation Configurations > Main enter image description here

Hibernate Code Generation Configurations > Exporters enter image description here

Hibernate version : 5.4

MySQL version Info

  • innodb_version:5.7.26
  • protocol_version:10
  • version:5.7.26-0ubuntu0.18.04.1
  • version_comment:(Ubuntu)
  • version_compile_machine:x86_64
  • version_compile_os:Linux
ironwood
  • 8,936
  • 15
  • 65
  • 114

1 Answers1

0

In this screen go to setup near reveng.xml. It will ask you to create a xml, from there you'll be able to exclude the databases you don't want.

In this screen

<hibernate-reverse-engineering>
    <table-filter match-name=".*" exclude="true" match-catalog="YOUR_DATABASE_NAME" />
</hibernate-reverse-engineering>
uri2x
  • 3,162
  • 1
  • 11
  • 25