首页 > 解决方案 > 没有使用 EcpliseLInk 2.6.7 选择正确的映射

问题描述

我已经使用 EclipseLink jar 2.6.7 创建了一个员工 hbm 文件,如果它返回 Regular_EMP 对象,那么它正在选择父类对象(包含 t)以在 Employee 表中插入数据,但是如果我使用 EclipseLink jar 2.6.5 和 Regular_EMP 对象它正在选择正确的子类 Regular_EMP 对象并在员工表中正确插入日期。为什么这是 EclipseLink jar2.6.7 的奇怪行为

<?xml version="1.0"?> 
<entity-mappings
xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm 
http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_1.xsd"
version="2.1">
<access>PROPERTY</access>
<entity class="Employee">
    <table name="EMP" />
    <discriminator-column name="C_TYPE"
        discriminator-type="STRING" />
    <sequence-generator sequence-name="SEQ_EMP"
        name="gen_securisation" allocation-size="1">
    </sequence-generator>
    <attributes>
        <id name="objId" access="FIELD">
            <column name="N__ID" />
            <generated-value strategy="SEQUENCE" generator="gen_emp" />
        </id>
        <basic name="level">
            <column name="N_LEVEL" />
        </basic>
    </attributes>
</entity>

<entity exclude-default-mappings="true"
    class="Regular_EMP">
    <table name="EMP" />
    <inheritance strategy="SINGLE_TABLE" />
    <discriminator-value>3</discriminator-value>
    <attributes>
        <basic name="SPI">
            <column name="B_SPI" />
    </attributes>
</entity>

而Regular_EMP 是emp 的子类。

标签: javaeclipselinkhibernate-mapping

解决方案


推荐阅读