0

I´m getting a weird behaviour using hibernate tools to generate my entities. I need the "java names" to respect some convension. So I configured de reveng.xml It´s like this:

<hibernate-reverse-engineering>
    <schema-selection match-schema="SCHEMA" match-table="PRE_.*" />

    <table-filter match-name="PRE_.*" package="com.my.ent"/>

    <table name="PRE_MY_TABLE" schema="SCHEMA" class="MyTable">
        <column name="C_ID" property="id" />
        <column name="C_COD" property="cod" />
    </table>
    <table name="PRE_MY_TABLE_2" schema="SCHEMA" class="MyTable2">
        <column name="C_ID" property="id" />
        <column name="C_COD" property="cod" />
    </table>
        ....
    <table name="PRE_MY_TABLE_N" schema="SCHEMA" class="MyTableN">
        <column name="C_ID" property="id" />
        <column name="C_COD" property="cod" />
    </table>
</hibernate-reverse-engineering>

What I spect is the resulting code (of entities 1 to N) to be located in the folder set in the tool conf with the folder structure inside (com.my.ent) and respecting the names set in the reveng file. Instead of that I´m getting the code located with the right folder structure but with the names exactly as in the DB.

I don´t get it, this is a simple procedure and I cant get it working well.

Any help will be apreciated.

Thanks in advance!

Emiliano Schiano
  • 1,862
  • 1
  • 25
  • 30

1 Answers1

0

Well, the problem was really simple to resolve.

The issue was in the table declaration.

Declaring the class unqualified, overrides the package declaration in the table filter, so the generated code goes to the root folder and the entities created dont contain the package declaration (using default).

The solution is to declare the table configuration as follows:

<table-filter match-name="PRE_.*" package="com.my.ent"/>

<table name="PRE_MY_TABLE" schema="SCHEMA" class="com.my.ent.MyTable">
    <column name="C_ID" property="id" />
    <column name="C_COD" property="cod" />
</table>

Cheers!

Emiliano Schiano
  • 1,862
  • 1
  • 25
  • 30