0

我使用休眠工具生成我的实体时出现了一种奇怪的行为。我需要“java名称”来尊重一些约定。所以我配置了 de reveng.xml 是这样的:

<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>

我所期望的是生成的代码(实体 1 到 N)将位于工具 conf 中设置的文件夹中,其中文件夹结构位于 (com.my.ent) 中,并尊重 reveng 文件中设置的名称。取而代之的是,我得到的代码位于正确的文件夹结构中,但名称与数据库中的名称完全相同。

我不明白,这是一个简单的程序,我无法让它正常工作。

任何帮助将不胜感激。

提前致谢!

4

1 回答 1

0

嗯,这个问题很容易解决。

问题出在表声明中。

声明类不合格,会覆盖表过滤器中的包声明,因此生成的代码将转到根文件夹,并且创建的实体不包含包声明(使用默认值)。

解决方法是声明表配置如下:

<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>

干杯!

于 2014-05-27T16:16:54.307 回答