4
我有一個抽象類產品和繼承的類ProductWithRecurrency:訪問從DQL繼承類屬性中的Symfony2
/**
* @ORM\Table(name= "product")
* @ORM\Entity(repositoryClass="Acme\StoreBundle\Entity\Repositories\ProductRepository")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="product_kind_id", type="integer")
* @ORM\DiscriminatorMap({"1" = "ProductFoo", "2" = "ProductWithRecurring"})
*/
abstract class Product
{
}
/**
*
* @ORM\Table(name="product_with_recurring")
* @ORM\Entity(repositoryClass ="Acme\StoreBundle\Entity\Repositories\ProductRepository")
*/
class ProductWithRecurring extends Product
{
/**
* @var Recurring $recurring
*
* @ORM\JoinColumn(name="recurring_id", referencedColumnName="id", nullable=false)
*/
protected $recurring;
}
我需要一些混合產品,並有「週期性」實體的信息時,產品是ProductWithRecurring實例。我在ProductRepository的方法與此DQL:
$dql = "SELECT p product
FROM Acme\StoreBundle\Entity\Product p
LEFT JOIN p.recurring rc
WHERE p.some_conditions";
顯然得到此異常:
[Semantical Error] line 0, col 1182 near 'rc
': Error: Class Acme\StoreBundle\Entity\Product has no association named recurring
難道我要補充的複雜查詢或我有一個概念上的錯誤?(我不是Symfony的專家,也不是專業知識)。
代碼中可能存在錯誤,我簡化了它以隔離問題。
我的英語不太好,希望你能理解我,謝謝!
到目前爲止,我在頂級類別中添加了循環屬性。不完全正確,但它的工作原理。 有什麼幫助嗎?謝謝! – EduBusquets 2013-04-08 09:55:09