FROM missing on QueryDSL












0















I'm using QueryDSL v4.1.4 to do this query



.select(/*many fields*/)
.from(_product)
.join(_event).on(_product.event.eq(_event))
.join(_customer).on(_event.customer.eq(_customer))
.leftJoin(_person).on(_customer.person.eq(_person))
.leftJoin(_organization).on(_customer.organization.eq(_organization))
.where(/*many filters*/)


My code generate this SQL



SELECT --many fields
FROM product t3
LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id),
event t4,
customer t0
WHERE --many filters


But I would expect that this SQL will be generated (this SQL work fine in my DBMS)



SELECT --many fields
FROM product t3,
event t4,
customer t0
LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id)
WHERE --many filters


When trying to execute the query this exception occurs



missing FROM-clause entry for table "t0" (customer)


Failed ideas to fix it




  • Add all meta-models on from clause (this produces a useless and very heavy query)

  • I'm also use fetchJoin() to try to force a join over other but I have the same result (exception missing FROM-clause)


Exist any way to force the order that a join is applied on a query?










share|improve this question





























    0















    I'm using QueryDSL v4.1.4 to do this query



    .select(/*many fields*/)
    .from(_product)
    .join(_event).on(_product.event.eq(_event))
    .join(_customer).on(_event.customer.eq(_customer))
    .leftJoin(_person).on(_customer.person.eq(_person))
    .leftJoin(_organization).on(_customer.organization.eq(_organization))
    .where(/*many filters*/)


    My code generate this SQL



    SELECT --many fields
    FROM product t3
    LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
    LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id),
    event t4,
    customer t0
    WHERE --many filters


    But I would expect that this SQL will be generated (this SQL work fine in my DBMS)



    SELECT --many fields
    FROM product t3,
    event t4,
    customer t0
    LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
    LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id)
    WHERE --many filters


    When trying to execute the query this exception occurs



    missing FROM-clause entry for table "t0" (customer)


    Failed ideas to fix it




    • Add all meta-models on from clause (this produces a useless and very heavy query)

    • I'm also use fetchJoin() to try to force a join over other but I have the same result (exception missing FROM-clause)


    Exist any way to force the order that a join is applied on a query?










    share|improve this question



























      0












      0








      0








      I'm using QueryDSL v4.1.4 to do this query



      .select(/*many fields*/)
      .from(_product)
      .join(_event).on(_product.event.eq(_event))
      .join(_customer).on(_event.customer.eq(_customer))
      .leftJoin(_person).on(_customer.person.eq(_person))
      .leftJoin(_organization).on(_customer.organization.eq(_organization))
      .where(/*many filters*/)


      My code generate this SQL



      SELECT --many fields
      FROM product t3
      LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
      LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id),
      event t4,
      customer t0
      WHERE --many filters


      But I would expect that this SQL will be generated (this SQL work fine in my DBMS)



      SELECT --many fields
      FROM product t3,
      event t4,
      customer t0
      LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
      LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id)
      WHERE --many filters


      When trying to execute the query this exception occurs



      missing FROM-clause entry for table "t0" (customer)


      Failed ideas to fix it




      • Add all meta-models on from clause (this produces a useless and very heavy query)

      • I'm also use fetchJoin() to try to force a join over other but I have the same result (exception missing FROM-clause)


      Exist any way to force the order that a join is applied on a query?










      share|improve this question
















      I'm using QueryDSL v4.1.4 to do this query



      .select(/*many fields*/)
      .from(_product)
      .join(_event).on(_product.event.eq(_event))
      .join(_customer).on(_event.customer.eq(_customer))
      .leftJoin(_person).on(_customer.person.eq(_person))
      .leftJoin(_organization).on(_customer.organization.eq(_organization))
      .where(/*many filters*/)


      My code generate this SQL



      SELECT --many fields
      FROM product t3
      LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
      LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id),
      event t4,
      customer t0
      WHERE --many filters


      But I would expect that this SQL will be generated (this SQL work fine in my DBMS)



      SELECT --many fields
      FROM product t3,
      event t4,
      customer t0
      LEFT OUTER JOIN person t1 ON (t0.p_id = t1.p_id)
      LEFT OUTER JOIN organization t2 ON (t0.o_id = t2.o_id)
      WHERE --many filters


      When trying to execute the query this exception occurs



      missing FROM-clause entry for table "t0" (customer)


      Failed ideas to fix it




      • Add all meta-models on from clause (this produces a useless and very heavy query)

      • I'm also use fetchJoin() to try to force a join over other but I have the same result (exception missing FROM-clause)


      Exist any way to force the order that a join is applied on a query?







      querydsl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 21:34









      a_horse_with_no_name

      300k46458550




      300k46458550










      asked Nov 14 '18 at 20:35









      Esvin GonzalezEsvin Gonzalez

      255




      255
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Why are there no joins on t3 or t4? I would have thought that this would result in the Cartesian product of these tables. Perhaps the joins are in the WHERE clause, which is not shown in the example? If so, why mix ANSI SQL and non ANSI SQL, rather than performing all the joins in the FROM clause? I don't think this is a querydsl issue but rather an issue with the SQL that you'd be best resolving first.



          To generate the SQL requested in your question, this should do the trick. However, you should refactor your query to do ANSI style joins in the FROM clause and querydsl will "just work".



          .select(/*many fields*/)
          .from(_product)
          .from(_event)
          .from(_customer)
          .leftJoin(_person).on(_customer.person.eq(_person))
          .leftJoin(_organization).on(_customer.organization.eq(_organization))
          .where(/*many filters*/)


          EDIT



          In the comments, Esvin points out there is a varargs version of the from method, so the three calls to the standard version of the from method can be reduced to one: .from(_product, _event, _customer)






          share|improve this answer


























          • The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple references from(_product, _event, _customer) the last table on from() method should be the table to use on leftJoin().on(/*here*/) and not forgeting add where clauses to join the tables "_event" and "_customer".

            – Esvin Gonzalez
            Nov 29 '18 at 21:48











          • Glad you got it working! I didn't see the varargs version of the from method. Nice!

            – Robert Bain
            Nov 29 '18 at 22:00











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308348%2ffrom-missing-on-querydsl%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Why are there no joins on t3 or t4? I would have thought that this would result in the Cartesian product of these tables. Perhaps the joins are in the WHERE clause, which is not shown in the example? If so, why mix ANSI SQL and non ANSI SQL, rather than performing all the joins in the FROM clause? I don't think this is a querydsl issue but rather an issue with the SQL that you'd be best resolving first.



          To generate the SQL requested in your question, this should do the trick. However, you should refactor your query to do ANSI style joins in the FROM clause and querydsl will "just work".



          .select(/*many fields*/)
          .from(_product)
          .from(_event)
          .from(_customer)
          .leftJoin(_person).on(_customer.person.eq(_person))
          .leftJoin(_organization).on(_customer.organization.eq(_organization))
          .where(/*many filters*/)


          EDIT



          In the comments, Esvin points out there is a varargs version of the from method, so the three calls to the standard version of the from method can be reduced to one: .from(_product, _event, _customer)






          share|improve this answer


























          • The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple references from(_product, _event, _customer) the last table on from() method should be the table to use on leftJoin().on(/*here*/) and not forgeting add where clauses to join the tables "_event" and "_customer".

            – Esvin Gonzalez
            Nov 29 '18 at 21:48











          • Glad you got it working! I didn't see the varargs version of the from method. Nice!

            – Robert Bain
            Nov 29 '18 at 22:00
















          0














          Why are there no joins on t3 or t4? I would have thought that this would result in the Cartesian product of these tables. Perhaps the joins are in the WHERE clause, which is not shown in the example? If so, why mix ANSI SQL and non ANSI SQL, rather than performing all the joins in the FROM clause? I don't think this is a querydsl issue but rather an issue with the SQL that you'd be best resolving first.



          To generate the SQL requested in your question, this should do the trick. However, you should refactor your query to do ANSI style joins in the FROM clause and querydsl will "just work".



          .select(/*many fields*/)
          .from(_product)
          .from(_event)
          .from(_customer)
          .leftJoin(_person).on(_customer.person.eq(_person))
          .leftJoin(_organization).on(_customer.organization.eq(_organization))
          .where(/*many filters*/)


          EDIT



          In the comments, Esvin points out there is a varargs version of the from method, so the three calls to the standard version of the from method can be reduced to one: .from(_product, _event, _customer)






          share|improve this answer


























          • The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple references from(_product, _event, _customer) the last table on from() method should be the table to use on leftJoin().on(/*here*/) and not forgeting add where clauses to join the tables "_event" and "_customer".

            – Esvin Gonzalez
            Nov 29 '18 at 21:48











          • Glad you got it working! I didn't see the varargs version of the from method. Nice!

            – Robert Bain
            Nov 29 '18 at 22:00














          0












          0








          0







          Why are there no joins on t3 or t4? I would have thought that this would result in the Cartesian product of these tables. Perhaps the joins are in the WHERE clause, which is not shown in the example? If so, why mix ANSI SQL and non ANSI SQL, rather than performing all the joins in the FROM clause? I don't think this is a querydsl issue but rather an issue with the SQL that you'd be best resolving first.



          To generate the SQL requested in your question, this should do the trick. However, you should refactor your query to do ANSI style joins in the FROM clause and querydsl will "just work".



          .select(/*many fields*/)
          .from(_product)
          .from(_event)
          .from(_customer)
          .leftJoin(_person).on(_customer.person.eq(_person))
          .leftJoin(_organization).on(_customer.organization.eq(_organization))
          .where(/*many filters*/)


          EDIT



          In the comments, Esvin points out there is a varargs version of the from method, so the three calls to the standard version of the from method can be reduced to one: .from(_product, _event, _customer)






          share|improve this answer















          Why are there no joins on t3 or t4? I would have thought that this would result in the Cartesian product of these tables. Perhaps the joins are in the WHERE clause, which is not shown in the example? If so, why mix ANSI SQL and non ANSI SQL, rather than performing all the joins in the FROM clause? I don't think this is a querydsl issue but rather an issue with the SQL that you'd be best resolving first.



          To generate the SQL requested in your question, this should do the trick. However, you should refactor your query to do ANSI style joins in the FROM clause and querydsl will "just work".



          .select(/*many fields*/)
          .from(_product)
          .from(_event)
          .from(_customer)
          .leftJoin(_person).on(_customer.person.eq(_person))
          .leftJoin(_organization).on(_customer.organization.eq(_organization))
          .where(/*many filters*/)


          EDIT



          In the comments, Esvin points out there is a varargs version of the from method, so the three calls to the standard version of the from method can be reduced to one: .from(_product, _event, _customer)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 29 '18 at 22:08

























          answered Nov 15 '18 at 20:00









          Robert BainRobert Bain

          3,69242039




          3,69242039













          • The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple references from(_product, _event, _customer) the last table on from() method should be the table to use on leftJoin().on(/*here*/) and not forgeting add where clauses to join the tables "_event" and "_customer".

            – Esvin Gonzalez
            Nov 29 '18 at 21:48











          • Glad you got it working! I didn't see the varargs version of the from method. Nice!

            – Robert Bain
            Nov 29 '18 at 22:00



















          • The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple references from(_product, _event, _customer) the last table on from() method should be the table to use on leftJoin().on(/*here*/) and not forgeting add where clauses to join the tables "_event" and "_customer".

            – Esvin Gonzalez
            Nov 29 '18 at 21:48











          • Glad you got it working! I didn't see the varargs version of the from method. Nice!

            – Robert Bain
            Nov 29 '18 at 22:00

















          The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple references from(_product, _event, _customer) the last table on from() method should be the table to use on leftJoin().on(/*here*/) and not forgeting add where clauses to join the tables "_event" and "_customer".

          – Esvin Gonzalez
          Nov 29 '18 at 21:48





          The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple references from(_product, _event, _customer) the last table on from() method should be the table to use on leftJoin().on(/*here*/) and not forgeting add where clauses to join the tables "_event" and "_customer".

          – Esvin Gonzalez
          Nov 29 '18 at 21:48













          Glad you got it working! I didn't see the varargs version of the from method. Nice!

          – Robert Bain
          Nov 29 '18 at 22:00





          Glad you got it working! I didn't see the varargs version of the from method. Nice!

          – Robert Bain
          Nov 29 '18 at 22:00




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308348%2ffrom-missing-on-querydsl%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues