Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][SF2] Relacje oraz dziedziczenie encji.
Fluke
post 4.10.2014, 14:36:16
Post #1





Grupa: Zarejestrowani
Postów: 247
Pomógł: 9
Dołączył: 20.09.2010
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Witam,

Mam problem z Doctrine 2 w Symfony2.
Mam taki schemat Encji:

W adnotacji między AbstractProductContainer a Product wygląda to tak:
Klasa AbstractProductContainer:
  1. /**
  2.  * @ORM\MappedSuperclass()
  3.  */
  4. abstract class AbstractProductContainer extends AbstractSettlement {
  5. /**
  6.   * @ORM\OneToMany(targetEntity="Product", mappedBy="settlement", cascade={"all"})
  7.   *
  8.   * @var Product[]
  9.   */
  10. protected $products;

Klasa Product:
  1. /**
  2.  * @ORM\Entity()
  3.  * @ORM\Table(name="settlements_has_products")
  4.  */
  5. class Product {
  6. /**
  7.   * @ORM\ManyToOne(targetEntity="AbstractProductContainer", inversedBy="products", cascade={"all"})
  8.   * @ORM\JoinColumn(name="settlement_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  9.   *
  10.   * @var AbstractProductContainer
  11.   */
  12. protected $settlement;

Oraz klasa AbstractSettlement:
  1. /**
  2.  * @ORM\Entity()
  3.  * @ORM\Table(name="settlements")
  4.  * @ORM\InheritanceType("JOINED")
  5.  * @ORM\DiscriminatorColumn(name="discr", type="string")
  6.  * @ORM\DiscriminatorMap({
  7.  * "bill"="Bill",
  8.  * "invoice"="Invoice",
  9.  * "proforma_invoice"="ProformaInvoice",
  10.  * "final_invoice"="FinalInvoice",
  11.  * })
  12.  */
  13. abstract class AbstractSettlement {}


I po wygenerowaniu schematu bazy poszło wszystko ok, w debugerze występuje taki błąd: The association Product#settlement refers to the inverse side field AbstractSettlement#products which does not exist.. Oczywiście aplikacja działa tak jak ma działać ale trochę mnie to denerwuje.
Ktoś ma jakieś propozycje ?

Ten post edytował Fluke 4.10.2014, 14:37:13
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 15:13