在<one-to-many> hibernate中不生成包含外键的表

时间:2016-08-13 06:37:34

标签: hibernate orm

<!-- language: xml -->
<class name="com.restroshop.dao.model.Order" table="ORDER" schema="dbrestro">
    <id name="id" column="order_id">
        <generator class="identity" />
    </id>
    <property name="pincode" column="pincode" />
    <list name="articles">
        <key column="order_id" not-null="true"/>
        <list-index column="index" base="0"/>
        <one-to-many class="com.restroshop.dao.model.ItemUnitPriceQuantity"/>
    </list>
</class>
<class name="com.restroshop.dao.model.ItemUnitPriceQuantity" table="BASKET_ITEM" schema="dbrestro">
    <id name="id" column="basket_item_id">
        <generator class="identity" />
    </id>
    <property name="articleName" column="article_name" />
</class>

理想情况下,应生成两个表,第一个ORDER和第二个应该是BASKET_ITEM。当我添加&lt;然后生成BASKET_ITEM中的list&gt; 标记。它正在生成

<list name="articles">
    <key column="order_id" not-null="true"/>
    <list-index column="index" base="0"/>
    <one-to-many class="com.restroshop.dao.model.ItemUnitPriceQuantity"/>
</list>

被注释掉了。

儿童班:

<!-- language: java -->
public class ItemUnitPriceQuantity extends BaseEntity implements Serializable {   
    private String articleName;

    public ItemUnitPriceQuantity() {

    }


    public String getArticleName() {
        return articleName;
    }

    public void setArticleName(String articleName) {
        this.articleName = articleName;
    }
}

包含子项列表的父类:

<!-- language : java -->
public class Order extends BaseEntity implements Serializable {

    /**
     * Delivery address
     */
    private String pincode;

    /**
     * The basket to be delivered
     */
    private List<ItemUnitPriceQuantity> articles;

    public String getPincode() {
        return pincode;
    }

    public void setPincode(String pincode) {
        this.pincode = pincode;
    }

    public List<ItemUnitPriceQuantity> getArticles() {
        return articles;
    }

    public void setArticles(List<ItemUnitPriceQuantity> articles) {
        this.articles = articles;
    }
}

我相信我有些愚蠢的错误。但无法发现它。

0 个答案:

没有答案