Hello Christian; Are you able to outline how you have the tables modeled in Cayenne as your question relies on that modelling.
Regards. -- Andrew Lindesay On Sat, 13 Jan 2024, at 10:59, Christian Gonzalez wrote: > Hi, I was wondering if there was a way to perform queries where the ending > table/class is different from the starting one. I have a query where the > result columns (the SELECT part) I want are from a different table than the > starting one. It looks something like this: > > SELECT t3.columnA, t3. columnB, t3. columnC > FROM catalog.dbo.tableA t0 > JOIN catalog.dbo.tableB t1 on t0.varA = t1.varA > JOIN catalog.dbo.tableC t2 on t1.varA = t2.varA, > JOIN catalog.dbo.tableD t3 on t2.varA = t3.varA > JOIN catalog.dbo.tableE t4 on t0.varA = t4.varA, > WHERE t4.varB = 'somevalue' > > The relationships are only one way, going from tableA to tableC the reason > being that the query is more efficient that way. > > The query is currently being done through a raw SQL string using > SQLTemplate but we are trying to update it to avoid having raw SQL > statements and using the cayenne ObjectSelect and Expressions instead. > > If not, is there a way to expose the PathTranslator classes to have a > little more control over how the path expressions are converted to SQL > statements? > > The project currently uses cayenne 4.2.M3 > > Thank you, > Christian