[TYPO3-mvc] Question concerning persistAll

Henjo Hoeksma me at henjohoeksma.nl
Mon Apr 16 10:37:40 CEST 2012


>
> The persistance manager is injected by DI. Should work as well, shouldn't
> it?

Yup, as far as I know :-)

I think what happens is this: during your action you persist. At the end of
the action the objectmanager does its work and persists as always. Since
the objects state is different than your manual changes, the objects state
overwrites your manual persistence and the end of it life cycle.

It all feels a bit dirty to me, but I figure if you redirect the object to
another action that fixes the sorting, which in turn redirects to the
action you want to end up in, you will be fine.


Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.


On Sun, Apr 15, 2012 at 21:03, Lorenz Ulrich <lorenz-typo3 at visol.ch> wrote:

> Hi Henjo
>
> The persistance manager is injected by DI. Should work as well, shouldn't
> it?
>
> Best regards,
>
> Lorenz
>
> Am 13.04.2012 17:08, schrieb Henjo Hoeksma:
>
>> Hi Lorenz,
>>
>> did you instantiated the PersistenceManager ?
>>
>> $persistenceManager =
>> $this->objectManager->get('Tx_**Extbase_Persistence_Manager');
>> $persistenceManager->**persistAll();
>>
>> Kind regards,
>>
>> Henjo
>>
>> Problems are small because we learned how to deal with them.
>> Problems are big because we need to learn how to deal with them.
>>
>>
>> On Fri, Apr 13, 2012 at 11:54, Lorenz Ulrich<lorenz-typo3 at visol.ch>
>>  wrote:
>>
>>  Hi there
>>>
>>> To hack around my ObjectStorage sorting problem, I want to manually
>>> manipulate the database after persisting changes.
>>>
>>> So I create a new group of works:
>>>
>>> $groupOfWorks = $this->objectManager->create('**
>>> **Tx_Artbase_Domain_Model_**
>>> GroupOfWorks');
>>> $groupOfWorks->setTitle($****groupTitle);
>>>
>>>
>>>
>>> I add the group of works to the exhibition:
>>>
>>> $this->exhibitionRepository->****findOneByUid($exhibitionUid);
>>> $exhibition->addGroupOfWorks($****groupOfWorks);
>>>
>>>
>>> And call persistAll():
>>>
>>> $this->persistenceManager->****persistAll();
>>>
>>>
>>>
>>> After that I want to manipulate the mm table an store the sorting:
>>>
>>> Tx_Artbase_Utility_****ObjectStorageSorting::****
>>> setSorting($exhibition->****getUid(),
>>> $groupOfWorks->getUid(), 999999, 'tx_artbase_exhibition_**
>>>
>>> groupofworks_mm');
>>>
>>>
>>> I always thought that calling persistAll would persist all objects and
>>> therefore also save all changes to the database. But it seems that this
>>> is
>>> not the case. The MySQL log shows the following entries:
>>>
>>> UPDATE tx_artbase_exhibition_****groupofworks_mm SET
>>>
>>> sorting_foreign='999999' WHERE uid_local = 9 AND uid_foreign = 34
>>>
>>> DELETE FROM tx_artbase_exhibition_****groupofworks_mm WHERE
>>> uid_local='9'
>>>
>>> INSERT INTO tx_artbase_exhibition_****groupofworks_mm (uid_local,
>>>
>>> uid_foreign, sorting) VALUES ('9', '13', '1')
>>> INSERT INTO tx_artbase_exhibition_****groupofworks_mm (uid_local,
>>>
>>> uid_foreign, sorting) VALUES ('9', '20', '2')
>>> INSERT INTO tx_artbase_exhibition_****groupofworks_mm (uid_local,
>>>
>>> uid_foreign, sorting) VALUES ('9', '24', '3')
>>>
>>> So obviously the DB changes are not made when I call persistAll() but
>>> later (and my manual change is overwritten).
>>>
>>> Can someone confirm that this is the case? Is there any way around it?
>>>
>>> Thanks and best regards,
>>>
>>> Lorenz
>>> ______________________________****_________________
>>> TYPO3-project-typo3v4mvc mailing list
>>> TYPO3-project-typo3v4mvc@**lis**ts.typo3.org <http://lists.typo3.org><
>>> TYPO3-project-**typo3v4mvc at lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
>>> >
>>> http://lists.typo3.org/cgi-****bin/mailman/listinfo/typo3-**<http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**>
>>> project-typo3v4mvc<http://**lists.typo3.org/cgi-bin/**
>>> mailman/listinfo/typo3-**project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>>> >
>>>
>>>
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>


More information about the TYPO3-project-typo3v4mvc mailing list