我是学说的新手。
我有这个实体'交易',它与级联刷新到实体'货物'有多对多关联 (单向)
我有这段代码:
$trans = $em->getRepository('bundle:Transaction')->find($id);
$form = $this->createForm($trans);
$form->handleRequest($request);
if ($isCancel)
{
$em->refresh($trans);
}
交易实体已被还原但货物实体未还原。 我错过了什么?
transaction.orm.xml:
<?xml version="1.0"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Oss\PWORegBundle\Entity\Transaction" table="pworeg_transaction">
<id name="id" type="integer" column="id">
<generator strategy="IDENTITY"/>
</id>
<field name="transactionType" type="string" length="255" nullable="true" column="transaction_type"/>
<many-to-many field="goods" target-entity="Oss\PWORegBundle\Entity\Goods">
<join-table name="transaction_goods">
<join-columns>
<join-column name="tcId" referenced-column-name="id" />
</join-columns>
<inverse-join-columns>
<join-column name="goodsTechId" referenced-column-name="id" unique="true" />
</inverse-join-columns>
</join-table>
<cascade>
<cascade-persist />
<cascade-remove />
<cascade-refresh />
</cascade>
</many-to-many>
<field name="status" type="string" length="3" nullable="true" column="status"/>
</entity>
</doctrine-mapping>
goods.orm.xml:
<?xml version="1.0"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Oss\PWORegBundle\Entity\Goods" table="goods">
<id name="id" type="integer" column="id">
<generator strategy="IDENTITY"/>
</id>
<field name="name" type="string" length="255" nullable="true" column="name"/>
<field name="type" type="string" length="255" nullable="true" column="type"/>
</entity>
</doctrine-mapping>