[TYPO3-mvc] Question concerning persistAll

Lorenz Ulrich lorenz-typo3 at visol.ch
Fri Apr 13 11:54:50 CEST 2012


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


More information about the TYPO3-project-typo3v4mvc mailing list