hibernate2中实体字段太长并且相似导致生成的原生sql字段名重复

1:错误的hbm.xml

<property name="holiday1" type="java.lang.String" >
            <column name="HOLIDAY1"/>
        </property>
        <property name="holiday1Start" type="java.util.Date">
            <column name="HOLIDAY1_START"/>
        </property>
        <property name="holiday1End" type="java.util.Date">
            <column name="HOLIDAY1_END"/>
        </property>
        <property name="holiday1Work1" type="java.util.Date">
            <column name="HOLIDAY1_WORK1"/>
        </property>
        <property name="holiday1Work2" type="java.util.Date">
            <column name="HOLIDAY1_WORK2"/>
        </property>
        <property name="holiday2" type="java.lang.String">
            <column name="HOLIDAY2"/>
        </property>
        <property name="holiday2Start" type="java.util.Date">
            <column name="HOLIDAY2_START"/>
        </property>
        <property name="holiday3" type="java.lang.String">
            <column name="HOLIDAY3"/>
        </property>
        <property name="holiday3Start" type="java.util.Date">
            <column name="HOLIDAY3_START"/>
        </property>

2:导致生成的原生sql字段别名重复.数据库报错ORA-00918: 未明确定义列

hol0_.HOLIDAY1START as HOLIDAY14_,--重复
hol0_.HOLIDAY1END   as HOLIDAY15_,
hol0_.HOLIDAY1WORK1 as HOLIDAY16_,
hol0_.HOLIDAY1WORK2 as HOLIDAY17_,
hol0_.HOLIDAY2      as HOLIDAY2,
hol0_.HOLIDAY2START as HOLIDAY29_,
hol0_.HOLIDAY2END   as HOLIDAY10_,
hol0_.HOLIDAY2WORK1 as HOLIDAY11_,
hol0_.HOLIDAY2WORK2 as HOLIDAY12_,
hol0_.HOLIDAY3      as HOLIDAY3,
hol0_.HOLIDAY3START as HOLIDAY14_,--重复

3解决方法就是把字段名改短

        <property name="holiday1" type="java.lang.String" >
            <column name="DAY1"/>
        </property>
        <property name="holiday1Start" type="java.util.Date">
            <column name="DAY1_START"/>---由HOLIDAY1_START改为DAY1_START
        </property>
        <property name="holiday1End" type="java.util.Date">
            <column name="DAY1_END"/>
        </property>
        <property name="holiday1Work1" type="java.util.Date">
            <column name="DAY1_WORK1"/>
        </property>
        <property name="holiday1Work2" type="java.util.Date">
            <column name="DAY1_WORK2"/>
        </property>
        <property name="holiday2" type="java.lang.String">
            <column name="DAY2"/>
        </property>
        <property name="holiday2Start" type="java.util.Date">
            <column name="DAY2_START"/>
        </property>
        <property name="holiday2End" type="java.util.Date">
            <column name="DAY2_END"/>
        </property>
        <property name="holiday2Work1" type="java.util.Date">
            <column name="DAY2_WORK1"/>
        </property>
        <property name="holiday2Work2" type="java.util.Date">
            <column name="DAY2_WORK2"/>
        </property>
        <property name="holiday3" type="java.lang.String">
            <column name="DAY3"/>
        </property>
        <property name="holiday3Start" type="java.util.Date">
            <column name="DAY3_START"/>
        </property>
        <property name="holiday3End" type="java.util.Date">
            <column name="DAY3_END"/>
        </property>
posted @ 2024-12-19 16:33  letmedown  阅读(1)  评论(0编辑  收藏  举报