<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
					xmlns:content="http://purl.org/rss/1.0/modules/content/"
					xmlns:wfw="http://wellformedweb.org/CommentAPI/"
					xmlns:atom="http://www.w3.org/2005/Atom"
				  >
<channel>
<atom:link rel="self"  type="application/rss+xml"  href="http://rulinux.net/rss_from_sect_4_subsect_13_thread_37376"  />
<title>rulinux.net - Форум - Web-development - Doctrine и наследование сущностей.</title>
<link>http://rulinux.net/</link>
<description><![CDATA[Портал о GNU/Linux и не только]]></description>
<image><title>rulinux.net - Форум - Web-development - Doctrine и наследование сущностей.</title>
<link>http://rulinux.net/</link>
<url>http://rulinux.net/rss_icon.png</url>
</image>
<item>
<title>Re:Doctrine и наследование сущностей.</title>
<link>https://rulinux.net/message.php?newsid=37376&amp;page=1#143554</link>
<guid>https://rulinux.net/message.php?newsid=37376&amp;page=1#143554</guid>
<pubDate>Fri, 15 Jun 2012 09:29:29 +0400</pubDate>
<description><![CDATA[<p>Кстати про дискриминатор. использование MappedSuperclass и дискриминаторов, как я понял, просто два разных подхода к наследованию сущностей.</p>]]></description>
</item>
<item>
<title>Re:Doctrine и наследование сущностей.</title>
<link>https://rulinux.net/message.php?newsid=37376&amp;page=1#143553</link>
<guid>https://rulinux.net/message.php?newsid=37376&amp;page=1#143553</guid>
<pubDate>Fri, 15 Jun 2012 09:22:16 +0400</pubDate>
<description><![CDATA[<p>С этим разобрался быстро. А вот с тем как <a href="http://rulinux.net/thread_37385_page_1#msg143549">добавлять сущности-потомки не меняя родителя</a> - нет. Нашел вот <a href="http://thoughtsofthree.com/2011/04/defining-discriminator-maps-at-child-level-in-doctrine-2-0/">хак</a> но это почти полное переписывание драйвера анотаций.</p>]]></description>
</item>
<item>
<title>Re:Doctrine и наследование сущностей.</title>
<link>https://rulinux.net/message.php?newsid=37376&amp;page=1#143550</link>
<guid>https://rulinux.net/message.php?newsid=37376&amp;page=1#143550</guid>
<pubDate>Fri, 15 Jun 2012 09:12:45 +0400</pubDate>
<description><![CDATA[<p>Так ты разобрался? Я недавно читал про это вроде всё решаемо. Моку поискать ссылку. А всё понял, ты начале про дескриминатор забыл похоже. </p>]]></description>
</item>
<item>
<title>Re:Doctrine и наследование сущностей.</title>
<link>https://rulinux.net/message.php?newsid=37376&amp;page=1#143483</link>
<guid>https://rulinux.net/message.php?newsid=37376&amp;page=1#143483</guid>
<pubDate>Thu, 14 Jun 2012 09:56:03 +0400</pubDate>
<description><![CDATA[<p>Собственно ответ </p><p></p><p><fieldset><legend>]</legend><code><br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @ORM\Entity(repositoryClass=&quot;RL\ForumBundle\Entity\ThreadRepository&quot;)<br />
&nbsp;* @ORM\Table(name=&quot;threads&quot;)<br />
&nbsp;* @ORM\InheritanceType(&quot;JOINED&quot;)<br />
&nbsp;* @ORM\DiscriminatorColumn(name=&quot;discr&quot;, type=&quot;string&quot;)<br />
&nbsp;* @ORM\DiscriminatorMap({&quot;thread&quot; = &quot;Thread&quot;, &quot;article&quot; = &quot;RL\ArticlesBundle\Entity\Article&quot;})<br />
&nbsp;* @ORM\HasLifecycleCallbacks()<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Thread<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;integer&quot;, name=&quot;id&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$id</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\OneToMany(targetEntity=&quot;RL\ForumBundle\Entity\Message&quot;, mappedBy=&quot;thread&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\OrderBy({&quot;id&quot; = &quot;ASC&quot;})<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$messages</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\ManyToOne(targetEntity=&quot;RL\ForumBundle\Entity\Subsection&quot;, inversedBy=&quot;threads&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$subsection</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;boolean&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$attached</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;datetime&quot;, name=&quot;timest&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$postingTime</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;datetime&quot;, name=&quot;changing_timest&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$changingTime</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//...</span><br />
&nbsp;</code></fieldset></p>]]></description>
</item>
<item>
<title>Doctrine и наследование сущностей.</title>
<link>https://rulinux.net/message.php?newsid=37376&amp;page=1#143481</link>
<guid>https://rulinux.net/message.php?newsid=37376&amp;page=1#143481</guid>
<pubDate>Thu, 14 Jun 2012 09:41:07 +0400</pubDate>
<description><![CDATA[<p>Есть две сущности. Thread и наследуемая от нее Article</p><p><fieldset><legend>]</legend><code><br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @ORM\Entity(repositoryClass=&quot;RL\ForumBundle\Entity\ThreadRepository&quot;)<br />
&nbsp;* @ORM\Table(name=&quot;threads&quot;)<br />
&nbsp;* @ORM\MappedSuperclass<br />
&nbsp;* @ORM\HasLifecycleCallbacks()<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Thread<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;integer&quot;, name=&quot;id&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$id</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\OneToMany(targetEntity=&quot;RL\ForumBundle\Entity\Message&quot;, mappedBy=&quot;thread&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$messages</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\ManyToOne(targetEntity=&quot;RL\ForumBundle\Entity\Subsection&quot;, inversedBy=&quot;threads&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$subsection</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;boolean&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$attached</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;datetime&quot;, name=&quot;timest&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$postingTime</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;datetime&quot;, name=&quot;changing_timest&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$changingTime</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//...</span><br />
&nbsp;</code></fieldset></p><p></p><p><fieldset><legend>]</legend><code><br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @ORM\Entity()<br />
&nbsp;* @ORM\Table(name=&quot;articles&quot;)<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Article <span style="color: #000000; font-weight: bold;">extends</span> Thread<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;boolean&quot;, name=&quot;approved&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$approved</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\ManyToOne(targetEntity=&quot;RL\SecurityBundle\Entity\User&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$approvedBy</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @ORM\Column(type=&quot;datetime&quot;, name=&quot;approve_timest&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000088;">$approveTimest</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//...</span><br />
&nbsp;</code></fieldset></p><p></p><p>При генерировании схемы доктрина создает таблицу отдельно для Thread и отдельно для Article. Притом в Article не включается поле subsection. Есть ли возможность сделать так:</p><p></p><p><fieldset><legend>]</legend><code><br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> Thread <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; id &nbsp; &nbsp;SERIAL <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--остальные поля сущности Thread</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp;</code></fieldset></p><p></p><p><fieldset><legend>]</legend><code><br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> Article <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; approved <span style="color: #993333; font-weight: bold;">BOOLEAN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--остальные поля сущности Article</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; INHERITS <span style="color: #66cc66;">&#40;</span>Thread<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp;</code></fieldset></p><p>?</p><p></p>]]></description>
</item>
</channel>
</rss>