Feature #55959


Joins on SubClasses

Added by Philipp Wrann over 10 years ago. Updated over 3 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Sprint Focus:


The Typo3DbBackend Class does not respect the possibility you join a table with the same table. This happens if you use SubClasses which are connected.

An alias should be taken there. I managed to make this work, but its just a very quick and dirty solution. I replaced the backend by a patched, its attached to this issue. Just ignore the other modifications.

The approach is the usage of alias and a additional param in the function for the parent.

The problem occured when i made a query like this


where the aggregate i want to filter is a SubClass of the same class my location is a subClass of. So the join looked like

select * from tx_ex_domain_model_object left join tx_ex_domain_model_object on ....

Because SuperClass and SubClasses are a feature of extbase this is a must-have.


PatchedTypo3DbBackend.php (14.6 KB) PatchedTypo3DbBackend.php Philipp Wrann, 2014-02-13 14:36

Related issues 2 (0 open2 closed)

Has duplicate TYPO3 Core - Bug #57629: Wrong SQL-Query with tow joins on same tableClosed2014-04-03

Is duplicate of TYPO3 Core - Bug #27057: Can't query on properties of child objects of the same classClosedAlexander Schnitzler2011-05-26

Actions #1

Updated by Philipp Wrann over 10 years ago

Actually this has impact on all kinds of relations to the same model, different example:

would result in
select * from person left join person on person.parent = person.uid where person.gender = 'male'

instead of
select * from person left join person as parent on person.parent = parent.uid where parent.gender = 'male'

Actions #2

Updated by André Wuttig over 10 years ago

Is this feature planned for 6.2 release?! We have huge problems because we cannot make custom queries with subclasses of the same type (table)!

I think there are three workarounds:

  • we have to build a second table, which have the same structure as the table of the subclass -> prevents alias problem
  • we have to make multiple custom queries
    • first search the subclass table
    • second search the parentclass table with "$query->in(...)"
      -> for many records this leads to a big performance problem, because in the first query many results will be possibly instantiated
  • we should use this patch
    • not good, because we dont know what the side-effects are

I will try the first solution (its overhead but i hope it works!)

Actions #3

Updated by Philipp Wrann over 10 years ago

The attached file is not working very well but having multiple tables sounds like a very bad solution.

I think its absolutely possible to use an alias. you just have to use the property path as key and generate an alias if neccessary (if table has been joined on a different propertypath allready or the root table is the same).

I think its not so much work! You just have to move the while construct, that generates the joins in a method, there you could work with a register.

I set target version to 6.2 because i see this as extbase core functionallity, subclassing and domain model inheritance is possible, so this has to be possible too.

Sadly i dont find time besides my regular work to provide a solution.

Actions #4

Updated by Marc Bastian Heinrichs over 10 years ago

  • Status changed from New to Accepted
  • Priority changed from Must have to Should have
  • Target version changed from 6.2.0 to next-patchlevel
Actions #5

Updated by Alexander Opitz almost 10 years ago

  • Project changed from 534 to TYPO3 Core
  • Category changed from Extbase: Generic Persistence to Extbase
  • Status changed from Accepted to New
Actions #6

Updated by Philipp Wrann over 9 years ago

Are there any news on this? We are planning a new version (for cms 7) of some big extension we developed and now we have to dicide if using the domain model inheritence is still an option.

Please send some feedback if any work/planning has taken place here.

thank you.

Actions #8

Updated by Mathias Schreiber over 8 years ago

  • Target version deleted (next-patchlevel)
Actions #9

Updated by André Wuttig over 8 years ago

When do you plan to fix this issue??

Actions #10

Updated by Mathias Brodala over 8 years ago

André Wuttig wrote:

When do you plan to fix this issue??

When someone confirms that it was already fixed with #27057. :-)

Actions #11

Updated by Susanne Moog over 4 years ago

  • Status changed from New to Needs Feedback

From Mathias comment this should have been fixed with #27057 - is this still happening?

Actions #12

Updated by Riccardo De Contardi over 3 years ago

  • Status changed from Needs Feedback to Closed

No feedback since the last 90 days => closing this issue.

If you think that this is the wrong decision or experience the issue again and have more information about how to reproduce your problem, please reopen it or open a new issue with a reference to this one.

Thank you and best regards.


Also available in: Atom PDF