[TYPO3-mvc] tt_content mapping, but findAll() dont work

Stephan Schuler Stephan.Schuler at netlogix.de
Wed May 14 16:08:47 CEST 2014


Hey Stefan.

Getting NULL as a result is very unusual and might point to some internal error. But I don't know of anything that retuns NULL instead of throwing an exception. Are you sure you really get NULL back from findAll() instead of an empty QueryResultInterface?

Keep in mind that the findByUid is a very special method!

On one hand there is that magic "findBy$propertyName()" call, which finds a couple of results matching that property. On the other hand there is the "findOneBy$propertyName()" call, which finds exactly one result matching that property. Notice the "One" part of the method name.
But in contrast to those, the "findByUid" call does find exactly one result, although one might expect it to return a couple of results according to pure method naming mechanisms. That's fine because nobody would really expect a couple of objects where the argument is primary key, so returning exactly one makes perfect sense here.
But this tiny thing shows one important fact: It's special and not covered by regular "findBy$propertyName" mechanisms.

Have a look at the Persistence\Repository and inspect the differences :).

The "findAll" creates a default query according to repository rules and executes it.
The "findByUid" creates a default query in the first place, but it skips storagePage and sysLanguage.

This means: No matter what's the repositories default configuration: findByUid will always find the result on any page or in any folder and in any language. The "findAll", in contrast, does respect both attributes, in case of the repository having no other configuration.

To change that configuration you need to know what Persistence\Repository->createQuery() does. It just uses the $repository->defaultQuerySettings and clones them to create an actual query object.

You could use the initializeObject() method of your repository to instanciate a distinct defaultQuerySettings object and call it to not respect the storage page. That's actually the preferred and documented way.
http://forge.typo3.org/projects/typo3v4-mvc/wiki/Default_Orderings_and_Query_Settings_in_Repository

Given the fact that you deal with tt_content, that's most likely exactly your problem because content usually does not live on a single storage page or folder but on nearly every page.

Regards,



Stephan Schuler
Web-Entwickler

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de



-----------------------------
PRTG Network Monitor
Lernen Sie, wie Sie Ihr Netz einfach und effektiv überwachen können. Jetzt anmelden zum netlogix-Event am 27.05.2014:
Jetzt anmelden: http://it-training.netlogix.de/angebote/events/prtg-network-monitor

Citrix XenApp & Desktop 7.5 – Das Wichtigste in einem Tag
Lernen Sie die neue Version kennen. Jetzt anmelden zum netlogix 79er Seminar am 18.06.2014 für nur 79.- EUR:
Jetzt anmelden: http://it-training.netlogix.de/angebote/79ers/citrix-xendesktop-75
------------------------------------



--
netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Stefan Kruse
Gesendet: Mittwoch, 14. Mai 2014 12:40
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: [TYPO3-mvc] tt_content mapping, but findAll() dont work

hi,

i made my own tt_content model and map it to the tt_content table.
I also made a tt_content repository.

When i use findByUid(8) then i got one object back

BUT

when i use findAll() the result is ever NULL.

I have no idea what this could.

Anybody some tipps, hints?

Thanks Stefan
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list