[TYPO3-mvc] Does the Persistence Layer not respect dirty objects?

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Thu Jun 7 02:33:22 CEST 2012


Hello guys,

I got a problem fetching domain objects
using a repository find method inside a loop.

Consider this:

--------------------------------------------------
$name = 'test';

foreach(...) {
    $object = $this->repository->findByName($name);

    if(!$object) {
       $this->repository->add($object);
    }
}

print $object->getName();
--------------------------------------------------

The problem is if $object is not yet in the
database, it won't be found - also on the
continuous loops it is not found, because
$this->repository->add() doesn't seem to
add it right away or $this->repository->findByName()
does not respect the newly added objects.

This also has the effect that $this->repository->add()
adds a duplicate to the database on every loop.

It only works if I use $persistenceManager->persistAll();
after every loop to ensure the object is added to the physical database.

But this is not good for the performance.

Any idea what I'm doing wrong or does the
persistence/repository really don't respect
dirty objects?

Thanks a lot!

PS: I'm using Extbase/Fluid 6.0.0-dev on TYPO3 6.0.0-dev on PHP 5.4.3.

Thomas


More information about the TYPO3-project-typo3v4mvc mailing list