Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hibernate代码生成异常行为_Java_Hibernate_Generated Code - Fatal编程技术网

Java Hibernate代码生成异常行为

Java Hibernate代码生成异常行为,java,hibernate,generated-code,Java,Hibernate,Generated Code,我使用hibernate工具生成实体时出现了一种奇怪的行为。 我需要java名称来遵守一些惯例。所以我配置了dereveng.xml 它是这样的: <hibernate-reverse-engineering> <schema-selection match-schema="SCHEMA" match-table="PRE_.*" /> <table-filter match-name="PRE_.*" package="com.my.ent"/&

我使用hibernate工具生成实体时出现了一种奇怪的行为。 我需要java名称来遵守一些惯例。所以我配置了dereveng.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>
I spect是实体1到N的结果代码,位于工具配置中的文件夹集中,文件夹结构位于com.my.ent内,并与reveng文件中设置的名称相关。 相反,我得到的代码具有正确的文件夹结构,但名称与数据库中的名称完全相同

我不明白,这是一个简单的程序,我不能让它工作得很好

任何帮助都将不胜感激


提前谢谢

这个问题很容易解决

问题在表格声明中

声明类为非限定类时,会覆盖表筛选器中的包声明,因此生成的代码将转到根文件夹,而使用默认值创建的实体不包含包声明

解决方案是按如下方式声明表配置:

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