FROM missing on QueryDSL
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
add a comment |
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
add a comment |
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
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
querydsl
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
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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)
The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple referencesfrom(_product, _event, _customer)
the last table onfrom()
method should be the table to use onleftJoin().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 thefrom
method. Nice!
– Robert Bain
Nov 29 '18 at 22:00
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)
The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple referencesfrom(_product, _event, _customer)
the last table onfrom()
method should be the table to use onleftJoin().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 thefrom
method. Nice!
– Robert Bain
Nov 29 '18 at 22:00
add a comment |
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)
The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple referencesfrom(_product, _event, _customer)
the last table onfrom()
method should be the table to use onleftJoin().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 thefrom
method. Nice!
– Robert Bain
Nov 29 '18 at 22:00
add a comment |
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)
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)
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 referencesfrom(_product, _event, _customer)
the last table onfrom()
method should be the table to use onleftJoin().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 thefrom
method. Nice!
– Robert Bain
Nov 29 '18 at 22:00
add a comment |
The problem is due to the order of my meta-models. Thanks @robert-bain, I just add multiple referencesfrom(_product, _event, _customer)
the last table onfrom()
method should be the table to use onleftJoin().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 thefrom
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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