我有两个实体,它们之间的关系定义如下:
<many-to-one
field="customer"
target-entity="ITME\UserBundle\Entity\User" inversed-by="orders">
<join-column name="customer_id" referenced-column-name="id"/>
</many-to-one>
/**
* @ORM\OneToMany(targetEntity="\ITME\OrderBundle\Entity\CustomerOrder",
mappedBy="customer")
*/
protected $orders;
当我添加一些订单并设置用户然后尝试从User获取这些订单时,订单的数组集合为空。知道我可能做错了吗?
答案 0 :(得分:0)
正如文件解释:
<many-to-one
field="category"
target-entity="Category"
inversed-by="products"
join-column="category">
<join-column name="category_id" referenced-column-name="id" />
</many-to-one>
希望它会对你有所帮助。