How do I wrap brackets around parameter values when using jOOq?
I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.
SELECT * FROM Product WHERE code LIKE ‘%al%’
So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.
Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks
java sql jooq hybris flexible-search
add a comment |
I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.
SELECT * FROM Product WHERE code LIKE ‘%al%’
So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.
Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks
java sql jooq hybris flexible-search
Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 '18 at 10:00
add a comment |
I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.
SELECT * FROM Product WHERE code LIKE ‘%al%’
So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.
Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks
java sql jooq hybris flexible-search
I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.
SELECT * FROM Product WHERE code LIKE ‘%al%’
So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.
Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks
java sql jooq hybris flexible-search
java sql jooq hybris flexible-search
edited Nov 13 '18 at 9:59
Lukas Eder
135k72439969
135k72439969
asked Nov 12 '18 at 15:03
user1272052user1272052
263
263
Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 '18 at 10:00
add a comment |
Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 '18 at 10:00
Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 '18 at 10:00
Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 '18 at 10:00
add a comment |
1 Answer
1
active
oldest
votes
You could indeed implement an ExecuteListener
that replaces
- every odd
"
by aand every even
"
by ausing any dialect (be careful of syntactic ambiguities)
- every odd
`
by aand every even
`
by ausing MySQL dialect
- every
[
by aand every
]
by ausing SQL Server dialect
But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.
Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener
and wrap them in ...
, but that, too, would be much easier to achieve by patching jOOQ directly.
Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overridingDefaultVisitLister
(I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I triedcontext.renderContext().render().replaceAll("[
]","[");` but I get NullPointer
– user1272052
Nov 15 '18 at 12:46
@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 '18 at 8:08
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%2f53264890%2fhow-do-i-wrap-brackets-around-parameter-values-when-using-jooq%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
You could indeed implement an ExecuteListener
that replaces
- every odd
"
by aand every even
"
by ausing any dialect (be careful of syntactic ambiguities)
- every odd
`
by aand every even
`
by ausing MySQL dialect
- every
[
by aand every
]
by ausing SQL Server dialect
But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.
Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener
and wrap them in ...
, but that, too, would be much easier to achieve by patching jOOQ directly.
Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overridingDefaultVisitLister
(I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I triedcontext.renderContext().render().replaceAll("[
]","[");` but I get NullPointer
– user1272052
Nov 15 '18 at 12:46
@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 '18 at 8:08
add a comment |
You could indeed implement an ExecuteListener
that replaces
- every odd
"
by aand every even
"
by ausing any dialect (be careful of syntactic ambiguities)
- every odd
`
by aand every even
`
by ausing MySQL dialect
- every
[
by aand every
]
by ausing SQL Server dialect
But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.
Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener
and wrap them in ...
, but that, too, would be much easier to achieve by patching jOOQ directly.
Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overridingDefaultVisitLister
(I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I triedcontext.renderContext().render().replaceAll("[
]","[");` but I get NullPointer
– user1272052
Nov 15 '18 at 12:46
@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 '18 at 8:08
add a comment |
You could indeed implement an ExecuteListener
that replaces
- every odd
"
by aand every even
"
by ausing any dialect (be careful of syntactic ambiguities)
- every odd
`
by aand every even
`
by ausing MySQL dialect
- every
[
by aand every
]
by ausing SQL Server dialect
But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.
Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener
and wrap them in ...
, but that, too, would be much easier to achieve by patching jOOQ directly.
You could indeed implement an ExecuteListener
that replaces
- every odd
"
by aand every even
"
by ausing any dialect (be careful of syntactic ambiguities)
- every odd
`
by aand every even
`
by ausing MySQL dialect
- every
[
by aand every
]
by ausing SQL Server dialect
But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.
Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener
and wrap them in ...
, but that, too, would be much easier to achieve by patching jOOQ directly.
edited Nov 13 '18 at 10:26
answered Nov 13 '18 at 9:59
Lukas EderLukas Eder
135k72439969
135k72439969
Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overridingDefaultVisitLister
(I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I triedcontext.renderContext().render().replaceAll("[
]","[");` but I get NullPointer
– user1272052
Nov 15 '18 at 12:46
@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 '18 at 8:08
add a comment |
Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overridingDefaultVisitLister
(I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I triedcontext.renderContext().render().replaceAll("[
]","[");` but I get NullPointer
– user1272052
Nov 15 '18 at 12:46
@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 '18 at 8:08
Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding
DefaultVisitLister
(I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[
]","[");` but I get NullPointer– user1272052
Nov 15 '18 at 12:46
Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding
DefaultVisitLister
(I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[
]","[");` but I get NullPointer– user1272052
Nov 15 '18 at 12:46
@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 '18 at 8:08
@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 '18 at 8:08
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%2f53264890%2fhow-do-i-wrap-brackets-around-parameter-values-when-using-jooq%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
Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 '18 at 10:00